Submission #6933616


Source Code Expand

Copy
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl

typedef long long ll;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int ans = 0;
    int n;
    cin >> n;
    vector<int> a(n + 1);
    vector<int> b(n);
    for(int i = 0; i < n + 1; i++)
    {
        cin >> a[i];
    }
    for(int i = 0; i < n; i++)
    {
        cin >> b[i];
    }
    for(int i = 0; i < n; i++)
    {
        if(a[i] < b[i])
        {
            ans += a[i];
            b[i] -= a[i];
            a[i] = 0;
            if(b[i] < a[i + 1])
            {
                ans += b[i];
                a[i + 1] -= b[i];
                b[i] = 0;
            }
            else
            {
                ans += a[i + 1];
                b[i] -= a[i + 1];
                a[i + 1] = 0;
            }
        }
        else
        {
            ans += b[i];
            a[i] -= b[i];
            b[i] = 0;
        }
    }
    cout << ans;

    return 0;
}

Submission Info

Submission Time
Task C - City Savers
User ahzong
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1193 Byte
Status WA
Exec Time 22 ms
Memory 1024 KB

Judge Result

Set Name All Sample
Score / Max Score 0 / 300 0 / 0
Status
AC × 4
WA × 13
AC × 3
Set Name Test Cases
All sample_01, sample_02, sample_03, testcase_01, testcase_02, testcase_03, testcase_04, testcase_05, testcase_06, testcase_07, testcase_08, testcase_09, testcase_10, testcase_11, testcase_12, testcase_13, testcase_14
Sample sample_01, sample_02, sample_03
Case Name Status Exec Time Memory
sample_01 AC 1 ms 256 KB
sample_02 AC 1 ms 256 KB
sample_03 AC 1 ms 256 KB
testcase_01 WA 14 ms 768 KB
testcase_02 WA 12 ms 640 KB
testcase_03 WA 22 ms 1024 KB
testcase_04 WA 22 ms 1024 KB
testcase_05 WA 6 ms 512 KB
testcase_06 WA 12 ms 640 KB
testcase_07 WA 20 ms 1024 KB
testcase_08 WA 21 ms 1024 KB
testcase_09 WA 17 ms 896 KB
testcase_10 WA 21 ms 1024 KB
testcase_11 WA 18 ms 896 KB
testcase_12 WA 2 ms 256 KB
testcase_13 WA 22 ms 1024 KB
testcase_14 AC 1 ms 256 KB