結果

問題 No.139 交差点
ユーザー chocoruskchocorusk
提出日時 2020-10-03 12:51:28
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 800 bytes
コンパイル時間 2,258 ms
コンパイル使用メモリ 74,180 KB
実行使用メモリ 56,432 KB
最終ジャッジ日時 2023-09-25 05:04:32
合計ジャッジ時間 8,420 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,452 KB
testcase_01 AC 124 ms
56,312 KB
testcase_02 AC 121 ms
55,636 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 133 ms
55,508 KB
testcase_09 AC 139 ms
55,936 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 139 ms
55,900 KB
testcase_19 AC 137 ms
56,348 KB
testcase_20 AC 131 ms
55,912 KB
testcase_21 AC 121 ms
55,884 KB
testcase_22 AC 118 ms
55,828 KB
testcase_23 WA -
testcase_24 AC 128 ms
55,692 KB
testcase_25 WA -
testcase_26 AC 130 ms
55,496 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintWriter;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scanner=new Scanner(System.in);
		PrintWriter out=new PrintWriter(System.out);
		int n=scanner.nextInt();
		int l=scanner.nextInt();
		int[] x=new int[n];
		int[] w=new int[n];
		int[] t=new int[n];
		for(int i=0; i<n; i++) {
			x[i]=scanner.nextInt();
			w[i]=scanner.nextInt();
			t[i]=scanner.nextInt();
		}
		int p=0;
		for(int i=0; i<n; i++) {
			if(i==0) p+=x[i];
			else p+=x[i]-(x[i-1]+w[i-1]);
			if(p/(2*t[i])%2==1) {
				p=(p/(2*t[i])+1)*2*t[i]+w[i];
			}else {
				int p0=p/(2*t[i])*2*t[i];
				if(t[i]-(p-p0)<w[i]) {
					p=p0+2*t[i]+w[i];
				}else {
					p+=w[i];
				}
			}
		}
		p+=l-(x[n-1]+w[n-1]);
		out.println(p);
		out.close();
		scanner.close();
	}
}
0