QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#369675 | #8057. Best Carry Player 4 | lizixin# | Compile Error | / | / | C++14 | 1.2kb | 2024-03-28 16:15:43 | 2024-03-28 16:15:45 |
Judging History
answer
#include <iostream>
using namespace std;
const int N = 5e5+100;
ll a[N], b[N], c[N];
int n;
using ll = long long;
void sol() {
cin >> n;
ll suma = 0, sumb = 0;
int Mxa = -1, Mxb = -1;
for (int i = 0; i < n; ++i) {
cin >> a[i];
suma += a[i];
if (a[i] > 0) Mxa = i;
}
for (int i = 0; i < n; ++i) {
cin >> b[i];
if (b[i] > 0) Mxb = i;
sumb += b[i];
}
if (suma > sumb) {
b[0] += suma - sumb;
} else if (sumb > suma) {
a[0] += sumb - suma;
}
bool flag = 0;
if (Mxa + Mxb < n) {
cout << 0 << '\n';
return;
}
ll cnta = 0, cntb = 0, ans = 0;
flag = 0;
for (int i = 0; i < n; ++i) {
if (cntb > 0 && a[i] > 0) {
flag = 1;
}
cnta = a[i];
cntb += b[n - 1 - i];
ll tmp = min(cnta, cntb);
ans += tmp;
cnta -= tmp;
cntb -= tmp;
}
if (!flag) {
ans -= 1;
}
cout << ans << '\n';
}
int main() {
ios::sync_with_stdio(0);
int T;
cin >> T;
while(T --) {
sol();
}
return 0;
}
Details
answer.code:6:1: error: ‘ll’ does not name a type 6 | ll a[N], b[N], c[N]; | ^~ answer.code: In function ‘void sol()’: answer.code:15:16: error: ‘a’ was not declared in this scope 15 | cin >> a[i]; | ^ answer.code:20:16: error: ‘b’ was not declared in this scope 20 | cin >> b[i]; | ^ answer.code:25:9: error: ‘b’ was not declared in this scope 25 | b[0] += suma - sumb; | ^ answer.code:27:9: error: ‘a’ was not declared in this scope 27 | a[0] += sumb - suma; | ^ answer.code:39:25: error: ‘a’ was not declared in this scope 39 | if (cntb > 0 && a[i] > 0) { | ^ answer.code:42:16: error: ‘a’ was not declared in this scope 42 | cnta = a[i]; | ^ answer.code:43:17: error: ‘b’ was not declared in this scope 43 | cntb += b[n - 1 - i]; | ^