結果
| 問題 |
No.139 交差点
|
| コンテスト | |
| ユーザー |
woodsgreen
|
| 提出日時 | 2022-01-14 02:47:09 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 22 ms / 5,000 ms |
| コード長 | 671 bytes |
| コンパイル時間 | 1,797 ms |
| コンパイル使用メモリ | 191,604 KB |
| 最終ジャッジ日時 | 2025-01-27 10:46:12 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int n,l,x[110],w[110],t[110];
// cur: ʱ, pos: λ
int cur,pos;
int main(){
cin>>n>>l;
for(int i=0;i<n;++i)
cin>>x[i]>>w[i]>>t[i];
for(int i=0;i<n;++i){
cur+=x[i]-pos;
pos=x[i];
// ̵лʱΪt[i]*2
// : ʱ=(t[i]*2)*p+ǰ̵ʱ
// : ǰ̵ʱ=ʱ%(t[i]*2)
// ·ʱ,Ҫ̵ͨ,ǰ̵ʣʱ䲻w[i]
// : ʱ%(t[i]*2)>t[i]-w[i], Ҫһ̵
if(cur%(t[i]*2)>t[i]-w[i])
cur+=t[i]*2-cur%(t[i]*2);
}
cout<<cur+l-pos<<endl;
return 0;
}
woodsgreen