QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#76323 | #2541. Coins and Boxes | Linshey# | WA | 26ms | 6256kb | C++14 | 604b | 2023-02-09 09:04:41 | 2023-02-09 09:04:43 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std; const int maxn = 2e5 + 5; typedef long long ll;
int n, B[maxn], C[maxn];
ll V[maxn]; int D[maxn], m;
int main()
{
scanf("%d", &n);
for (int i = 1; i <= n; i++) scanf("%d", B + i);
for (int i = 1; i <= n; i++) scanf("%d", C + i);
for (int i = 1; i <= n; i++) if (B[i] < C[i])
{
++m;
V[m] = (C[i] - B[i]) * 2 + V[m - 1];
D[m] = B[i];
}
int U = max(B[n], C[n]);
ll ans = V[m];
for (int i = m; i; i--) ans = min(ans, U - D[i] + V[i - 1]);
printf("%lld\n", ans + U);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 5792kb
input:
4 1 6 7 12 3 5 10 11
output:
21
result:
ok answer is '21'
Test #2:
score: 0
Accepted
time: 2ms
memory: 5560kb
input:
2 1 2 1 1000000000
output:
1999999998
result:
ok answer is '1999999998'
Test #3:
score: -100
Wrong Answer
time: 26ms
memory: 6256kb
input:
100000 967 3246 9492 10300 15195 16650 26911 54855 83695 112841 125511 137160 153051 155859 177924 187843 214838 219388 247276 249612 250188 253873 257830 261805 281312 297030 298332 325904 333218 339683 374111 387794 396645 403705 426710 436137 463368 481801 501933 509267 511332 515225 515629 51686...
output:
1999994467
result:
wrong answer expected '1722240547', found '1999994467'