Educational Codeforces Round 158 (Rated for Div. 2)

Problem - A - Codeforces

#include
#define endl '\n'
#define int long long
using namespace std;
const int N=55;
int a[N];
int n,x;
void solve() {
	cin>>n>>x;
	for(int i=1;i<=n;i++) cin>>a[i];
	a[n+1]=1000;
	int ans=0;
	int pos=lower_bound(a+1,a+1+n+1,x)-a;
	pos--;
//	cout<>t;
	while(t--) {
		solve();
	}
	return 0;
}

Problem - B - Codeforces

#include
#define endl '\n'
#define int long long
using namespace std;
const int N=2e5+10;
int a[N];
int n;
void solve() {
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	int ans=0;
	ans+=a[1]-1;
	for(int i=2;i<=n;i++){
		if(a[i]>=a[i-1]) ans+=a[i]-a[i-1];
	}
	cout<>t;
	while(t--) {
		solve();
	}
	return 0;
}

Problem - C - Codeforces

#include
#define endl '\n'
#define int long long
using namespace std;
const int N=2e5+10;
int a[N];
int n;
void solve() {
	cin>>n;
	int maxn=0;
	int minn=2e9;
	for(int i=1;i<=n;i++) cin>>a[i],maxn=max(maxn,a[i]),minn=min(minn,a[i]);
	if(maxn==minn){
		cout<<0<c;
	while(maxn!=minn+1){
		ans++;
		if(minn%2){
			maxn++;
			minn++;
			c.push_back(1);
		}
		else{
			c.push_back(0);
		}
		maxn/=2;
		minn/=2;
		if(maxn==0) break;
	}
	if(maxn==minn+1){
		cout<>t;
	while(t--) {
		solve();
	}
	return 0;
}

你可能感兴趣的:(codeforces,算法,c++)