Submission #759214
Source Code Expand
#include<bits/stdc++.h> using namespace std; #define int long long typedef pair<int,int>pint; typedef vector<int>vint; typedef vector<pint>vpint; #define pb push_back #define mp make_pair #define fi first #define se second #define all(v) (v).begin(),(v).end() #define rep(i,n) for(int i=0;i<(n);i++) #define reps(i,f,n) for(int i=(f);i<(n);i++) #define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++) template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;} template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;} const int INF=1001001001001001001ll; int N; int A[111111]; int B[111111]; signed main(){ cin>>N; rep(i,N)cin>>A[i]; rep(i,N)cin>>B[i]; int maxval=-INF; int maxB=-INF; int cnt=0,val=0; rep(i,N+1){ chmax(maxB,B[i]); chmax(maxval,val+(N-cnt)*maxB); if(i==N)break; int cost=1; if(val+A[i]<0){ if(maxB<=0)break; int tmp=(-A[i]-val+maxB-1)/maxB; cost+=tmp; } if(cnt+cost>N)break; val+=A[i]+(cost-1)*maxB; cnt+=cost; } cout<<maxval<<endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - 高橋君の旅行 |
User | latte0119 |
Language | C++11 (GCC 4.9.2) |
Score | 200 |
Code Size | 1211 Byte |
Status | AC |
Exec Time | 186 ms |
Memory | 2472 KB |
Judge Result
Set Name | Small | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 3 / 3 | 197 / 197 | ||||
Status |
|
|
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 | 31 ms | 860 KB |
00_small_sample_01.txt | AC | 28 ms | 1032 KB |
00_small_sample_02.txt | AC | 28 ms | 904 KB |
00_small_sample_03.txt | AC | 28 ms | 856 KB |
10_small_01.txt | AC | 30 ms | 892 KB |
10_small_02.txt | AC | 28 ms | 924 KB |
10_small_03.txt | AC | 28 ms | 860 KB |
10_small_04.txt | AC | 28 ms | 880 KB |
10_small_05.txt | AC | 27 ms | 928 KB |
10_small_06.txt | AC | 28 ms | 1048 KB |
20_large_01.txt | AC | 154 ms | 2456 KB |
20_large_02.txt | AC | 180 ms | 2420 KB |
20_large_03.txt | AC | 176 ms | 2460 KB |
20_large_04.txt | AC | 154 ms | 2464 KB |
20_large_05.txt | AC | 178 ms | 2460 KB |
20_large_06.txt | AC | 178 ms | 2456 KB |
20_large_07.txt | AC | 158 ms | 2396 KB |
20_large_08.txt | AC | 177 ms | 2464 KB |
20_large_09.txt | AC | 177 ms | 2388 KB |
20_large_10.txt | AC | 154 ms | 2388 KB |
20_large_11.txt | AC | 174 ms | 2464 KB |
20_large_12.txt | AC | 178 ms | 2460 KB |
20_large_13.txt | AC | 136 ms | 2464 KB |
20_large_14.txt | AC | 154 ms | 2460 KB |
20_large_15.txt | AC | 154 ms | 2460 KB |
20_large_16.txt | AC | 134 ms | 2456 KB |
20_large_17.txt | AC | 156 ms | 2464 KB |
20_large_18.txt | AC | 156 ms | 2448 KB |
20_large_19.txt | AC | 150 ms | 2460 KB |
20_large_20.txt | AC | 172 ms | 2460 KB |
20_large_21.txt | AC | 172 ms | 2400 KB |
20_large_22.txt | AC | 128 ms | 2452 KB |
20_large_23.txt | AC | 150 ms | 2460 KB |
20_large_24.txt | AC | 154 ms | 2452 KB |
20_large_25.txt | AC | 150 ms | 2456 KB |
20_large_26.txt | AC | 172 ms | 2448 KB |
20_large_27.txt | AC | 174 ms | 2464 KB |
20_large_28.txt | AC | 156 ms | 2456 KB |
20_large_29.txt | AC | 170 ms | 2460 KB |
20_large_30.txt | AC | 170 ms | 2472 KB |
30_run_through_01.txt | AC | 167 ms | 2388 KB |
70_maximum_01.txt | AC | 186 ms | 2468 KB |
80_hand_01.txt | AC | 85 ms | 2472 KB |
80_hand_02.txt | AC | 87 ms | 2468 KB |
80_hand_03.txt | AC | 86 ms | 2472 KB |
80_hand_04.txt | AC | 85 ms | 2388 KB |
90_small_teuchi_00.txt | AC | 27 ms | 864 KB |
90_small_teuchi_01.txt | AC | 27 ms | 928 KB |
90_small_teuchi_02.txt | AC | 27 ms | 932 KB |