結果
問題 | No.139 交差点 |
ユーザー |
![]() |
提出日時 | 2015-01-30 00:03:39 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,432 bytes |
コンパイル時間 | 1,810 ms |
コンパイル使用メモリ | 160,372 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-23 04:18:52 |
合計ジャッジ時間 | 5,562 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | AC * 1 WA * 27 |
ソースコード
#define _CRT_SECURE_NO_WARNINGS //#define _GLIBCXX_DEBUG #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef pair<int,int> pii; #define all(c) (c).begin(), (c).end() #define loop(i,a,b) for(ll i=a; i<ll(b); i++) #define rep(i,b) loop(i,0,b) #define pb push_back #define eb emplace_back #define mp make_pair #define mt make_tuple template<class T> istream& operator>>(istream& is, vector<T>& v); template<class T> ostream& operator<<(ostream& os, vector<T> const& v); template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream&, const tuple<T...>&){} template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream& os, const tuple<T...>& t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); } template<class...T> ostream& operator<<(ostream& os, const tuple<T...>& t){ _ot<0>(os, t); return os; } template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _it(istream&, tuple<T...>&){} template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _it(istream& is, tuple<T...>& t){ is >> get<n>(t); _it<n+1>(is, t); } template<class...T> istream& operator>>(istream& is, tuple<T...>& t){ _it<0>(is, t); return is; } template<class T> istream& operator>>(istream& is, vector<T>& v){ rep(i,v.size()) is >> v[i]; return is; } template<class T> ostream& operator<<(ostream& os, vector<T> const& v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; } #ifdef DEBUG #define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl) #else #define dump(...) #endif int flg[111111]; int main(){ int N,L; while(cin>>N>>L){ memset(flg,-1,sizeof(flg)); vi x(N), w(N), t(N); rep(i,N){ cin >> x[i] >> w[i] >> t[i]; fill(flg+x[i], flg+x[i]+w[i], i); } dump(vi(flg,flg+L+1)); int pos = 0; int time=0; int k=0; int cnt=0; while(1){ if(pos==L) break; if(flg[pos]!=-1 && flg[pos+1]==-1){ if(time/t[k]%2==1 || // red t[k]-time%t[k] > w[k]){ // blue cnt++; } else { pos++; k++; } } else { pos++; } time++; } cout << time << endl; } }