# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
987527 |
2024-05-23T00:58:34 Z |
cig32 |
Fruits (NOI22_fruits) |
C++17 |
|
76 ms |
19428 KB |
#include "bits/stdc++.h"
#define int long long
using namespace std;
const int MAXN = 4e5 + 10;
void solve(int tc) {
int n;
cin >> n;
int a[n+1], c[n+1];
for(int i=1; i<=n; i++) cin >> a[i];
for(int i=1; i<=n; i++) cin >> c[i];
int sumci = 0;
int sumai = 0;
for(int i=1; i<=n; i++) {
sumci += c[i];
sumai += a[i];
}
if(sumci == n) {
int mx = 0, ans = 0;
for(int i=1; i<=n; i++) {
if(a[i] == -1) {
if(mx < n) {
mx++;
ans++;
}
}
else {
if(a[i] > mx) {
ans++;
mx = a[i];
}
}
cout << ans << " \n"[i == n];
}
return;
}
if(sumai == -n) {
int ps[n+1];
ps[0] = 0;
for(int i=1; i<=n; i++) {
ps[i] = ps[i-1] + c[i];
}
for(int i=1; i<=n; i++) {
cout << ps[n] - ps[n - i] << " \n"[i == n];
}
return;
}
}
int32_t main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t=1; //cin>>t;
for(int i=1; i<=t; i++) solve(i);
}
/*
g++ T2443.cpp -std=c++17 -O2 -o T2443
./T2443 < input.txt
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
4 ms |
1116 KB |
Output is correct |
4 |
Correct |
39 ms |
10064 KB |
Output is correct |
5 |
Correct |
76 ms |
19428 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
66 ms |
11348 KB |
Output is correct |
2 |
Incorrect |
66 ms |
11344 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |