Submission #6566945


Source Code Expand

Copy
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define st first
#define nd second
#define all(x) x.begin(),x.end()
using namespace std;
const int MX = 1e5+8;
int n,a[MX],b[MX];
int main(){
    cin >> n;
    for(int i=0 ; i<n+1 ; ++i)
        cin >> a[i];
    for(int i=0 ; i<n ; ++i)
        cin >> b[i];
    ll ans = 0;
    for(int i=0 ; i<n ; ++i){
        ll num = min(b[i],a[i]);
        b[i] -= num;
        a[i] -= num;
        ans += num;
        num = min(b[i],a[i+1]);
        ans += num;
        b[i] -= num;
        a[i+1] -=num;
    }
    cout << ans << "\n";
}

Submission Info

Submission Time
Task C - City Savers
User CHAOSCONTROL
Language C++14 (GCC 5.4.1)
Score 300
Code Size 650 Byte
Status AC
Exec Time 116 ms
Memory 1024 KB

Judge Result

Set Name All Sample
Score / Max Score 300 / 300 0 / 0
Status
AC × 17
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 AC 65 ms 768 KB
testcase_02 AC 57 ms 640 KB
testcase_03 AC 106 ms 1024 KB
testcase_04 AC 104 ms 1024 KB
testcase_05 AC 20 ms 512 KB
testcase_06 AC 42 ms 640 KB
testcase_07 AC 73 ms 1024 KB
testcase_08 AC 107 ms 1024 KB
testcase_09 AC 82 ms 896 KB
testcase_10 AC 107 ms 1024 KB
testcase_11 AC 89 ms 896 KB
testcase_12 AC 3 ms 256 KB
testcase_13 AC 116 ms 1024 KB
testcase_14 AC 1 ms 256 KB