Cutting Codeforces Round #493 (Div. 2)
Posted tp25959
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Cutting Codeforces Round #493 (Div. 2)相关的知识,希望对你有一定的参考价值。
#include<cstdio> #include<cstring> #include<algorithm> #include<iostream> #include<string> #include<vector> #include<stack> #include<bitset> #include<cstdlib> #include<cmath> #include<set> #include<list> #include<deque> #include<map> #include<queue> #define INF 0x3f3f3f3f; #define ll long long ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);} using namespace std; const int manx=1e5+10; int main() { int n,m,a[110],ans=0,cnt1=0,cnt2=0,b[110],c=0,sum=0; cin>>n>>m; for(int i=0; i<n; i++) cin>>a[i]; for(int i=0; i<n; i++) { if(a[i]%2) cnt1++; else cnt2++; if(cnt1==cnt2&&i+1<n) b[c++]=abs(a[i]-a[i+1]); } sort(b,b+c); for(int i=0; i<c; i++) { sum+=b[i]; if(sum<=m) ans++; else break; } cout<<ans; return 0; }
以上是关于Cutting Codeforces Round #493 (Div. 2)的主要内容,如果未能解决你的问题,请参考以下文章
Codeforces Round #540 (Div. 3) F1. Tree Cutting (Easy Version) DFS
Codeforces Round #521 (Div. 3) D. Cutting Out
codeforces 1077D Cutting Out 二分