提出 #6933616


ソースコード 拡げる

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

提出情報

提出日時
問題 C - City Savers
ユーザ ahzong
言語 C++14 (GCC 5.4.1)
得点 0
コード長 1193 Byte
結果 WA
実行時間 22 ms
メモリ 1024 KiB

ジャッジ結果

セット名 All Sample
得点 / 配点 0 / 300 0 / 0
結果
AC × 4
WA × 13
AC × 3
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
sample_01 AC 1 ms 256 KiB
sample_02 AC 1 ms 256 KiB
sample_03 AC 1 ms 256 KiB
testcase_01 WA 14 ms 768 KiB
testcase_02 WA 12 ms 640 KiB
testcase_03 WA 22 ms 1024 KiB
testcase_04 WA 22 ms 1024 KiB
testcase_05 WA 6 ms 512 KiB
testcase_06 WA 12 ms 640 KiB
testcase_07 WA 20 ms 1024 KiB
testcase_08 WA 21 ms 1024 KiB
testcase_09 WA 17 ms 896 KiB
testcase_10 WA 21 ms 1024 KiB
testcase_11 WA 18 ms 896 KiB
testcase_12 WA 2 ms 256 KiB
testcase_13 WA 22 ms 1024 KiB
testcase_14 AC 1 ms 256 KiB