結果
問題 | No.139 交差点 |
ユーザー |
![]() |
提出日時 | 2016-02-15 01:26:55 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 690 bytes |
コンパイル時間 | 570 ms |
コンパイル使用メモリ | 72,632 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 06:44:46 |
合計ジャッジ時間 | 1,429 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#include <algorithm>#include <cstdio>#include <iostream>#include <map>#include <math.h>#include <queue>#include <set>#include <sstream>#include <stack>#include <string>#include <vector>using namespace std;#define ll long long#define INF (1 << 30)#define INFLL (1LL << 60)ll n,l;ll ans = 0,now = 0;ll x,w,t;int main() {cin >> n >> l;for(int i = 0;i < n;i++){cin >> x >> w >> t;ans += x - now;now += x - now;if((ans / t) % 2 == 0){if(t - ans % t >= w) {ans += w;now += w;}else{ans += t - ans % t + t + w;now += w;}}else{ans += t - ans % t + w;now += w;}}ans += l - now;cout << ans << endl;return 0;}