結果

問題 No.139 交差点
コンテスト
ユーザー 184
提出日時 2015-01-30 00:13:24
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 533 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 275 ms
コンパイル使用メモリ 54,348 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2026-03-07 18:55:08
合計ジャッジ時間 945 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <cstdio>
#include <cstring>
#include <cstdlib> 
#include <algorithm>
 
using namespace std;

//namaega184


int main(){
	int n,l,x[101],w[101],t[101];scanf("%d%d",&n,&l);
	bool b[101];
	for(int i=0;i<n;i++){
		scanf("%d%d%d",&x[i],&w[i],&t[i]);
		b[i]=1;
	} 
	int ans=0,pos=0,tm=0;
	for(int i=0;i<n;i++){
		ans+=x[i]-pos;
		pos=x[i];
		if(ans/t[i]%2)ans+=w[i]+(t[i]-ans%t[i]);
		else{
			if((t[i]-ans%t[i])<w[i])ans+=w[i]+(t[i]-ans%t[i])+t[i];
			else ans+=w[i];
		}
		pos+=w[i];
	}
	
	printf("%d\n",ans+l-pos);
	return 0;
}
0