Educational Codeforces Round 90 (Rated for Div. 2) A~C

Educational Codeforces Round 90 (Rated for Div. 2) A~C_第1张图片

直接判断单价和单买就可以


#include
#include
using namespace std;
#define rep(i,j,k) for(LL i=(j); i<(k); ++i)
#define pb push_back
#define PII pair
#define PLL pair
#define ini(a,j) memset(a,j,sizeof a)
#define rrep(i,j,k) for(LL i=j; i>=k; --i)
#define fi first
#define se second
#define LL long long
#define beg begin()
#define ed end()
#define all(x) x.begin(),x.end()


int main(int argc, char const *argv[])
{
	// #define DEBUG
    	#ifdef DEBUG
		freopen("1.dat","r",stdin);
		freopen("ans.dat","w",stdout);
	#endif
	LL _;
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>_;
	while(_--){
		LL a,b,c;
		cin>>a>>b>>c;
		LL ans1=-1;
		LL ans2=-1;
		if(ac)
			ans2 = b;
		cout<

Educational Codeforces Round 90 (Rated for Div. 2) A~C_第2张图片

仔细思考会发现,少的那个总会被消除完的,因为不可能使得两个都有剩下而不相邻

#include
#include
using namespace std;
#define rep(i,j,k) for(LL i=(j); i<(k); ++i)
#define pb push_back
#define PII pair
#define PLL pair
#define ini(a,j) memset(a,j,sizeof a)
#define rrep(i,j,k) for(LL i=j; i>=k; --i)
#define fi first
#define se second
#define LL long long
#define beg begin()
#define ed end()
#define all(x) x.begin(),x.end()

// const int N = 1e5+10;
// int a[N];

int main(int argc, char const *argv[])
{
	// #define DEBUG
    	#ifdef DEBUG
		freopen("1.dat","r",stdin);
		freopen("ans.dat","w",stdout);
	#endif
	LL _;
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>_;
	while(_--){
		// 少的那个总是可以消除完的
		string s;
		cin>>s;
		int c = count(all(s),'0');
		int c2 = s.length()-c;
		c = min(c, c2);
		if(c&1)
			cout<<"DA"<

Educational Codeforces Round 90 (Rated for Div. 2) A~C_第3张图片

记录一波前缀和,每次向后找更小的负数,记录到答案的cnt里就可以


#include
#include
using namespace std;
#define rep(i,j,k) for(LL i=(j); i<(k); ++i)
#define pb push_back
#define PII pair
#define PLL pair
#define ini(a,j) memset(a,j,sizeof a)
#define rrep(i,j,k) for(LL i=j; i>=k; --i)
#define fi first
#define se second
#define LL long long
#define beg begin()
#define ed end()
#define all(x) x.begin(),x.end()

const int N = 1e6+10;
int a[N];

int main(int argc, char const *argv[])
{
	// #define DEBUG
    	#ifdef DEBUG
		freopen("1.dat","r",stdin);
		freopen("ans.dat","w",stdout);
	#endif
	LL _;
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>_;
	while(_--){
		string s;
		cin>>s;
		a[0]=0;
		rep(i,1,s.length()+1)
			if(s[i-1]=='+')
				a[i]=a[i-1]+1;
			else
				a[i] =a[i-1]-1;
		// 遇到的每一个负数,都是要进去一次的
		LL ma = 0;
		LL ans = 0;
		LL used = 0;
		rep(i,1,s.length()+1){
			if(a[i]>=0)
				continue;
			if(a[i]

你可能感兴趣的:(Educational Codeforces Round 90 (Rated for Div. 2) A~C)