QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#413624 | #6751. Game | Arnold_6 | RE | 0ms | 0kb | C++17 | 682b | 2024-05-17 20:06:48 | 2024-05-17 20:06:49 |
answer
# include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 200010;
int n;
int a[N];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for(int i = 1; i <= n; i ++) cin >> a[i];
LL res = 0;
for(int i = 1; i <= n; i ++)
{
if(i < n)
{
int t = min(a[i], a[i + 1]);
res += t;
a[i] -= t, a[i + 1] -= t;
}
if(i == n)
{
int t = min(a[i], a[1]);
res += t;
a[i] -= t, a[i + 1] -= t;
}
}
cout << res << endl;
system("pause");
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Dangerous Syscalls
input:
2 7 5
output:
5