跳到正文

个人记录

CPS-J 9.17模拟赛

NothingIsImpossible约 3 分钟
原文

这是 2026年9月17日 存档的第 4 版,不是当前版本。查看当前版本

文章信息与版本

文章信息

发布
2026年9月17日
收录
2026年9月17日
更新
2026年11月22日
篇幅
约 3 分钟

版本

  1. v8当前
  2. v7
  3. v6
  4. v5
更早的 4 个版本
  1. v4
  2. v3
  3. v2
  4. v1

A.

C++
#include<bits/stdc++.h>
using namespace std;
inline int read() {
    int x=0, f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9') {
        if(ch=='-') f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9') {
        x=x*10+(ch-'0');
        ch=getchar();
    }
    return x*f;
}

int main(){
	freopen("hint.in","r",stdin);
	freopen("hint.out","w",stdout);
	ios::sync_with_stdio(false);
	cout.tie(0);
	int q=read(),a=read(),b=read();
	vector<int> ans;
	while(q--){
		int y=read(),m=read(),d=read();
		if(m>a){
			ans.push_back(y+1);
		}
		else{
			if(m==a and d>=b) ans.push_back(y+1);
			else ans.push_back(y);
		}
	}
	for(int n:ans) cout<<n<<endl;
	return 0;
	}


















#include<bits/stdc++.h>
using namespace std;
int main(){
	freopen("spearshield.in","r",stdin);
	freopen("spearshield.out","w",stdout);
	int n;
	cin>>n;
	string s;
	cin>>s;
	s="/"+s;
	int mi=2147483600;
	for(int i=0;i<=n;i++){
		long long jg=0,fs=0;
		for(int j=0;j<=i;j++)if(s[j]=='0') jg+=j;
		for(int j=n;j>i;j--) if(s[j]=='1') fs+=j; 
		mi=(abs(jg-fs)>mi)?mi:abs(jg-fs);
		
	}
	cout<<mi;
	return 0;
	}