Codeforces Round 917 (Div. 2)
1.Codeforces Round 909 (Div. 3)2.Codeforces Round 910 (Div. 2)3.Codeforces Round 912 (Div. 2)4.Educational Codeforces Round 158 (Rated for Div. 2)5.Codeforces Round 911 (Div. 2)6.[Educational Codeforces Round 159 (Rated for Div. 2)](https://codeforces.com/contest/1902)7.[Codeforces Round 855 (Div. 3)](https://codeforces.com/contest/1800)8.Codeforces Round 913 (Div. 3)9.Codeforces Round 904 (Div. 2)10.Codeforces Round 914 (Div. 2)
11.Codeforces Round 917 (Div. 2)
12.Codeforces [Hello 2024]13.Codeforces Round 919 (Div. 2)14.Codeforces Round 920 (Div. 3)Codeforces Round 917 (Div. 2)
康复训练
A. Least Product
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int n;
void solve(){
cin >> n;
int cnt = 0;
bool ok = false;
// cout << endl;
// cout << n <<endl;
for(int i = 1;i <=n ; i++)
{
int x;
cin >> x;
//cout << i << endl;
//cout << x << " " <<endl;
if(x < 0) cnt++;
if(x ==0) ok=true;
}
//cout << endl;
//cout << ok <<" " << cnt <<endl;
if(ok || (cnt&1)){
cout << 0 << endl;
}else{
cout << 1 << endl;
cout << "1 0" << endl;
}
}
int main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int T = 1;
cin >> T;
while(T--) solve();
return 0;
}
B. Erase First or Second Letter
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
int n;
bool a[26];
void solve(){
string s;
memset(a,false,sizeof a);
cin >> n >> s;
int ans = 0 ;
for(int i=0;i<s.size();i++){
if(!a[s[i]-'a']){
a[s[i]-'a'] = true;
ans += n - i;
}
}
cout << ans << endl;
}
int main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int T = 1;
cin >> T;
while(T--) solve();
return 0;
}
C. Watering an Array
注意注意注意ans不能初始化为d/2。
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
const int N = 1e5 + 10;
int n,k,d;
int a[N],b[N];
void solve(){
cin>>n>>k>>d;
long long cnt = 0;
for(int i = 1;i<=n;i++){
cin >> a[i];
if(a[i]==i) cnt++;
}
for(int i = 1;i<=k;i++) cin>>b[i];
long long ans = 0;
for(int i = 1;i<=d && i<=n*2+1;i++){
ans = max(ans,cnt + (d-i)/2);
int len = i%k;
if(len==0) len = k;
len = b[len];
for(int j=1;j<=len;j++){
if(a[j]==j) cnt--;
a[j]++;
if(a[j]==j) cnt++;
}
}
cout << ans <<endl;
}
signed main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int T = 1;
cin >> T;
while(T--) solve();
return 0;
}
合集:
cf
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧