本文代码亲测AC
如有不足请指正
A题
代码
#include <bits/stdc++.h>
using namespace std;
int main(){
int n,t,a;
cin >> n >> t >> a;
int num = n - (t + a);
if (t >= a and t > a + num){cout << "Yes"; exit(0);}
if (t <= a and t + num < a){cout << "Yes"; exit(0);}
cout << "No" << endl;
return 0;
}
思路
几种不同的情况:
- t > a, 剩下的票 -> 全给t or a ?
- t < a,同理
- 其他皆为不可以确定
B题
代码
#include <bits/stdc++.h>
using namespace std;
int main(){
string s[111];
int n,mx = 1;
cin >> n;
for (int i = 1;i <= n;i ++){cin >> s[i];mx = max(mx,int(s[i].size()));}
for (int i = 0;i < mx;i ++){
string ans;
for (int j = n;j >= 1;j --){
ans.push_back((s[j].size() > i ? s[j][i]:'*'));
}
while (ans[ans.size() -1] == '*') ans.pop_back();
cout << ans << endl;
}
return 0;
}
思路
一位一位对齐,最后去星号
C题
代码
#include <bits/stdc++.h>
using namespace std;
int main(){
int q;
map<int,int> m;
set<int> s;
cin >> q;
while (q --){
int token;
cin >> token;
if (token == 3) {cout << s.size() << endl;continue;}
int x;
cin >> x;
if (token == 1){s.insert(x);m[x] ++;}
else {
if (m[x] == 1){s.erase(x);m[x]--;}
else m[x] --;
}
}
return 0;
}
思路
map用于记录数量,set看共多少个数
细节:
当x号球已被取完时,set里也要erase掉
你的点赞是我最大的支持
试试点上去吧
注释:
由于ipad编辑,所以暂时无法形成可复制代码版本,即将在2024年8月11日晚上更新
新标题名:Atcoder Beginner Contest 366 A - C(更新版本)