Submission #1275871


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n);
    vector<int> asum(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++) cin>>b[i];
    const long long int INF=1e10;
    vector<pair<long long int,int>> reach(n+1,{INF,INF});
    reach[0]={0,0};
    int ma=b[0];
    for(int i=1;i<n+1;i++){
        asum[i-1]+=a[i-1];
        int cost=reach[i-1].second;
        if(cost+a[i]>=0){
            reach[i]={reach[i].first+1,cost+a[i]};
        }
        else{
            if(ma==0){
                break;
            }
            int times=(cost+a[i])/ma+((cost+a[i])%ma==0);
            reach[i]={reach[i].first+times,ma*times+cost+a[i]};
        }
        if(i==n) break;
        ma=max(ma,b[i]);
    }
    long long int res=0;
    for(int i=0;i<n;i++){
        if(reach[i].first<=n){
            res=max(res,reach[i].second+(n-reach[i].first)*b[i]);
        }
        if(n==i) break;
        ma=max(ma,b[i]);
    }
    cout<<res<<endl;
    return 0;
}

Submission Info

Submission Time
Task D - 高橋君の旅行
User nikutto
Language C++14 (GCC 5.4.1)
Score 0
Code Size 1080 Byte
Status WA
Exec Time 89 ms
Memory 2944 KB

Judge Result

Set Name Small All
Score / Max Score 0 / 3 0 / 197
Status
AC × 4
WA × 9
AC × 7
WA × 42
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 1 ms 256 KB
00_small_sample_01.txt WA 1 ms 256 KB
00_small_sample_02.txt AC 1 ms 256 KB
00_small_sample_03.txt WA 1 ms 256 KB
10_small_01.txt WA 1 ms 256 KB
10_small_02.txt WA 1 ms 256 KB
10_small_03.txt AC 1 ms 256 KB
10_small_04.txt WA 1 ms 256 KB
10_small_05.txt WA 1 ms 256 KB
10_small_06.txt WA 1 ms 256 KB
20_large_01.txt AC 74 ms 2944 KB
20_large_02.txt WA 85 ms 2944 KB
20_large_03.txt WA 84 ms 2944 KB
20_large_04.txt WA 74 ms 2944 KB
20_large_05.txt WA 84 ms 2944 KB
20_large_06.txt WA 85 ms 2944 KB
20_large_07.txt WA 73 ms 2944 KB
20_large_08.txt WA 84 ms 2944 KB
20_large_09.txt WA 85 ms 2944 KB
20_large_10.txt WA 72 ms 2944 KB
20_large_11.txt WA 83 ms 2944 KB
20_large_12.txt WA 83 ms 2944 KB
20_large_13.txt WA 61 ms 2944 KB
20_large_14.txt WA 73 ms 2944 KB
20_large_15.txt WA 73 ms 2944 KB
20_large_16.txt WA 60 ms 2944 KB
20_large_17.txt WA 71 ms 2944 KB
20_large_18.txt WA 72 ms 2944 KB
20_large_19.txt WA 70 ms 2944 KB
20_large_20.txt WA 81 ms 2944 KB
20_large_21.txt WA 81 ms 2944 KB
20_large_22.txt WA 57 ms 2944 KB
20_large_23.txt WA 69 ms 2944 KB
20_large_24.txt WA 69 ms 2944 KB
20_large_25.txt WA 70 ms 2944 KB
20_large_26.txt WA 81 ms 2944 KB
20_large_27.txt WA 81 ms 2944 KB
20_large_28.txt WA 69 ms 2944 KB
20_large_29.txt WA 81 ms 2944 KB
20_large_30.txt WA 81 ms 2944 KB
30_run_through_01.txt WA 79 ms 2944 KB
70_maximum_01.txt AC 89 ms 2944 KB
80_hand_01.txt AC 34 ms 2944 KB
80_hand_02.txt WA 33 ms 2944 KB
80_hand_03.txt WA 34 ms 2944 KB
80_hand_04.txt WA 33 ms 2944 KB
90_small_teuchi_00.txt WA 1 ms 256 KB
90_small_teuchi_01.txt AC 1 ms 256 KB
90_small_teuchi_02.txt WA 1 ms 256 KB