ABC446我的代码+C求调
2026-02-21 21:45:25
发布于:江西
A
AC
#include <bits/stdc++.h>
using namespace std;
int main() {
string s;
cin >> s;
cout << "Of" << char(s[0] + 32);
for (int i = 1; i < s.size(); i++) cout << s[i];
return 0;
}
B
AC
#include <bits/stdc++.h>
using namespace std;
int a[1000005];
int main() {
int n, m;
cin >> n >> m;
for (int i = 0; i < n; i++) {
int L, res = 0;
cin >> L;
for (int j = 0; j < L; j++) {
int x;
cin >> x;
if (a[x] == 0 && res == 0)
res = x;
}
cout << res << " ";
a[res] = 1;
}
return 0;
}
C
28AC+2TLE
#include <bits/stdc++.h>
using namespace std;
struct node {
int x, y;
};
int main() {
int t;
cin >> t;
for (int i = 0; i < t; i++) {
int n, d, day = 0, ans = 0, a[200005], b[200005];
cin >> n >> d;
queue<node> q;
for (int j = 1; j <= n; j++) cin >> a[j];
for (int j = 1; j <= n; j++) cin >> b[j];
for (int j = 1; j <= n; j++) {
day++;
int aa = a[j], bb = b[j];
q.push({day, aa});
while (bb > 0) {
if (q.front().y <= bb) {
bb -= q.front().y;
q.pop();
} else {
q.front().y -= bb;
bb = 0;
}
}
if (!q.empty() && day - q.front().x >= d) {
q.pop();
}
}
while (!q.empty()) {
ans += q.front().y;
q.pop();
}
cout << ans << endl;
}
return 0;
}
全部评论 1
看着像 AI
2026-02-21 来自 重庆
0没有啊
2026-02-24 来自 江西
0

























有帮助,赞一个