結果
問題 | No.2694 The Early Bird Catches The Worm |
ユーザー |
|
提出日時 | 2024-04-02 09:18:23 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 751 bytes |
コンパイル時間 | 3,184 ms |
コンパイル使用メモリ | 77,016 KB |
実行使用メモリ | 73,488 KB |
最終ジャッジ日時 | 2024-09-30 23:06:04 |
合計ジャッジ時間 | 59,899 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 20 WA * 52 |
ソースコード
import java.util.Scanner;class Main{public static void main(String[] args){Scanner sc = new Scanner(System.in);int N = sc.nextInt();int H = sc.nextInt();int[] A = new int[N];for(int i=0;i<N;i++)A[i] = sc.nextInt();long[] sumA = new long[N+1];for(int i=0;i<N;i++)sumA[i+1] = sumA[i]+A[i];long[] B = new long[N];for(int i=0;i<N;i++)B[i] = sc.nextInt();long[] sumB = new long[N+1];for(int i=0;i<N;i++)sumB[i+1] = sumB[i]+B[i];long ans = 0;long now = 0;int r = 0;for(int l=0;l<N;l++){if(B[l]>H)continue;while(r<N&&now+B[r]*(r-l+1)<=H){now += B[r]*(r-l+1);r++;}ans = Math.max(ans,sumA[r]-sumA[l]);now -= sumB[r]-sumB[l];}System.out.println(ans);}}