Submission #535515


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;

    rep(i,N+1){
        if(i!=N)ma=max(ma,B[i]);
        ans=max(ans,(N-cur)*ma+val);
        if(cur==N)break;

        if(val+A[i]>=0)val+=A[i];
        else{
            if(!ma)break;
            int tmp=(-(val+A[i])+ma-1)/ma;
            cur+=tmp;
            val+=tmp*ma;
        }
        cur++;
        if(cur>N)break;
    }

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

Submission Info

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

Judge Result

Set Name Small All
Score / Max Score 0 / 3 0 / 197
Status
AC × 11
WA × 2
AC × 29
WA × 20
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 23 ms 920 KB
00_small_sample_01.txt WA 24 ms 796 KB
00_small_sample_02.txt AC 22 ms 924 KB
00_small_sample_03.txt AC 23 ms 796 KB
10_small_01.txt WA 22 ms 928 KB
10_small_02.txt AC 23 ms 924 KB
10_small_03.txt AC 24 ms 924 KB
10_small_04.txt AC 23 ms 924 KB
10_small_05.txt AC 23 ms 928 KB
10_small_06.txt AC 25 ms 796 KB
20_large_01.txt WA 151 ms 2340 KB
20_large_02.txt WA 172 ms 2328 KB
20_large_03.txt WA 172 ms 2336 KB
20_large_04.txt WA 151 ms 2336 KB
20_large_05.txt WA 175 ms 2356 KB
20_large_06.txt WA 175 ms 2344 KB
20_large_07.txt WA 154 ms 2348 KB
20_large_08.txt WA 174 ms 2340 KB
20_large_09.txt WA 173 ms 2272 KB
20_large_10.txt WA 148 ms 2340 KB
20_large_11.txt WA 171 ms 2344 KB
20_large_12.txt WA 170 ms 2336 KB
20_large_13.txt WA 131 ms 2332 KB
20_large_14.txt WA 150 ms 2332 KB
20_large_15.txt WA 154 ms 2344 KB
20_large_16.txt WA 130 ms 2336 KB
20_large_17.txt WA 151 ms 2340 KB
20_large_18.txt WA 152 ms 2336 KB
20_large_19.txt AC 148 ms 2336 KB
20_large_20.txt AC 167 ms 2340 KB
20_large_21.txt AC 165 ms 2340 KB
20_large_22.txt AC 126 ms 2332 KB
20_large_23.txt AC 147 ms 2340 KB
20_large_24.txt AC 148 ms 2332 KB
20_large_25.txt AC 145 ms 2332 KB
20_large_26.txt AC 168 ms 2344 KB
20_large_27.txt AC 169 ms 2344 KB
20_large_28.txt AC 147 ms 2336 KB
20_large_29.txt AC 168 ms 2276 KB
20_large_30.txt AC 167 ms 2332 KB
30_run_through_01.txt AC 164 ms 2208 KB
70_maximum_01.txt AC 178 ms 2348 KB
80_hand_01.txt AC 82 ms 2332 KB
80_hand_02.txt AC 82 ms 2336 KB
80_hand_03.txt AC 83 ms 2340 KB
80_hand_04.txt AC 82 ms 2332 KB
90_small_teuchi_00.txt AC 24 ms 924 KB
90_small_teuchi_01.txt AC 27 ms 928 KB
90_small_teuchi_02.txt AC 25 ms 804 KB