結果

問題 No.139 交差点
ユーザー Rp7rf
提出日時 2015-01-30 22:27:46
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 897 bytes
コンパイル時間 735 ms
コンパイル使用メモリ 73,420 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-23 04:28:47
合計ジャッジ時間 1,682 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)

int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  int n,l;
  cin>>n>>l;
  vector<int> x(n);
  vector<int> w(n);
  vector<int> t(n);
  rep(i,n)
    cin>>x[i]>>w[i]>>t[i];
  x.push_back(l);

  int times = x[0];
  rep(i,n){
    if(times%(2*t[i])<t[i] && (times+w[i])%(2*t[i])<=t[i]){
      times+=w[i];
    }else{
      times += 2*t[i] - times % (2*t[i]);
      times += w[i];
    }
    times += x[i+1] - (x[i]+w[i]);
  }
  cout<<times<<endl;
  return 0;
}
0