Submission #535511


Source Code Expand

#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define int long long
int N;
int A[101010],B[101010];

signed main(){
    cin>>N;
    rep(i,N)cin>>A[i];
    rep(i,N)cin>>B[i];

    int ans=0;
    int ma=0,cur=0,val=0,latte=0;

    rep(i,N){
        ma=max(ma,B[i]);
        if(cur>N)break;
        ans=max(ans,(N-cur)*ma+val);
        if(cur==N)break;
        if(val+A[i]>=0){
            cur++;
            val+=A[i];
            continue;
        }
        if(ma==0)break;
        val+=A[i];
        int tmp=((-val)+ma-1)/ma;
        val+=tmp*ma;
        cur+=tmp+1;
    }

    cout<<ans<<endl;
    return 0;
}

Submission Info

Submission Time
Task D - 高橋君の旅行
User latte0119
Language C++ (GCC 4.9.2)
Score 0
Code Size 747 Byte
Status WA
Exec Time 226 ms
Memory 2544 KB

Judge Result

Set Name Small All
Score / Max Score 0 / 3 0 / 197
Status
AC × 12
WA × 1
AC × 43
WA × 6
Set Name Test Cases
Small 00_small_sample_00.txt, 00_small_sample_01.txt, 00_small_sample_02.txt, 00_small_sample_03.txt, 10_small_01.txt, 10_small_02.txt, 10_small_03.txt, 10_small_04.txt, 10_small_05.txt, 10_small_06.txt, 90_small_teuchi_00.txt, 90_small_teuchi_01.txt, 90_small_teuchi_02.txt
All 00_small_sample_00.txt, 00_small_sample_01.txt, 00_small_sample_02.txt, 00_small_sample_03.txt, 10_small_01.txt, 10_small_02.txt, 10_small_03.txt, 10_small_04.txt, 10_small_05.txt, 10_small_06.txt, 20_large_01.txt, 20_large_02.txt, 20_large_03.txt, 20_large_04.txt, 20_large_05.txt, 20_large_06.txt, 20_large_07.txt, 20_large_08.txt, 20_large_09.txt, 20_large_10.txt, 20_large_11.txt, 20_large_12.txt, 20_large_13.txt, 20_large_14.txt, 20_large_15.txt, 20_large_16.txt, 20_large_17.txt, 20_large_18.txt, 20_large_19.txt, 20_large_20.txt, 20_large_21.txt, 20_large_22.txt, 20_large_23.txt, 20_large_24.txt, 20_large_25.txt, 20_large_26.txt, 20_large_27.txt, 20_large_28.txt, 20_large_29.txt, 20_large_30.txt, 30_run_through_01.txt, 70_maximum_01.txt, 80_hand_01.txt, 80_hand_02.txt, 80_hand_03.txt, 80_hand_04.txt, 90_small_teuchi_00.txt, 90_small_teuchi_01.txt, 90_small_teuchi_02.txt
Case Name Status Exec Time Memory
00_small_sample_00.txt AC 53 ms 920 KB
00_small_sample_01.txt AC 29 ms 1052 KB
00_small_sample_02.txt AC 28 ms 872 KB
00_small_sample_03.txt AC 28 ms 868 KB
10_small_01.txt AC 27 ms 872 KB
10_small_02.txt AC 30 ms 1048 KB
10_small_03.txt AC 28 ms 864 KB
10_small_04.txt AC 26 ms 1048 KB
10_small_05.txt AC 26 ms 860 KB
10_small_06.txt AC 25 ms 1044 KB
20_large_01.txt AC 156 ms 2524 KB
20_large_02.txt AC 178 ms 2484 KB
20_large_03.txt AC 179 ms 2480 KB
20_large_04.txt AC 156 ms 2476 KB
20_large_05.txt AC 177 ms 2460 KB
20_large_06.txt AC 175 ms 2484 KB
20_large_07.txt AC 154 ms 2532 KB
20_large_08.txt AC 178 ms 2484 KB
20_large_09.txt AC 180 ms 2544 KB
20_large_10.txt AC 152 ms 2396 KB
20_large_11.txt AC 172 ms 2480 KB
20_large_12.txt AC 226 ms 2460 KB
20_large_13.txt AC 138 ms 2480 KB
20_large_14.txt AC 157 ms 2524 KB
20_large_15.txt AC 155 ms 2524 KB
20_large_16.txt AC 134 ms 2528 KB
20_large_17.txt AC 153 ms 2520 KB
20_large_18.txt AC 153 ms 2476 KB
20_large_19.txt WA 152 ms 2480 KB
20_large_20.txt AC 172 ms 2484 KB
20_large_21.txt AC 175 ms 2532 KB
20_large_22.txt AC 130 ms 2424 KB
20_large_23.txt AC 153 ms 2476 KB
20_large_24.txt AC 150 ms 2480 KB
20_large_25.txt WA 151 ms 2480 KB
20_large_26.txt AC 173 ms 2484 KB
20_large_27.txt AC 170 ms 2460 KB
20_large_28.txt WA 149 ms 2476 KB
20_large_29.txt AC 171 ms 2480 KB
20_large_30.txt AC 175 ms 2484 KB
30_run_through_01.txt WA 169 ms 2480 KB
70_maximum_01.txt AC 182 ms 2476 KB
80_hand_01.txt AC 85 ms 2460 KB
80_hand_02.txt AC 86 ms 2524 KB
80_hand_03.txt AC 87 ms 2460 KB
80_hand_04.txt WA 87 ms 2480 KB
90_small_teuchi_00.txt AC 28 ms 1036 KB
90_small_teuchi_01.txt AC 27 ms 1048 KB
90_small_teuchi_02.txt WA 29 ms 1040 KB