QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#413624#6751. GameArnold_6RE 0ms0kbC++17682b2024-05-17 20:06:482024-05-17 20:06:49

Judging History

你现在查看的是最新测评结果

  • [2024-05-17 20:06:49]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-05-17 20:06:48]
  • 提交

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;
}

詳細信息

Test #1:

score: 0
Dangerous Syscalls

input:

2
7 5

output:

5

result: