結果
問題 | No.139 交差点 |
ユーザー |
![]() |
提出日時 | 2015-01-29 23:36:48 |
言語 | C++11 (gcc 4.8.5) |
結果 |
AC
|
実行時間 | 3 ms |
コード長 | 1,258 Byte |
コンパイル時間 | 487 ms |
使用メモリ | 8,916 KB |
最終ジャッジ日時 | 2019-02-06 23:25:53 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
sample1.txt | AC | 2 ms
6,872 KB |
sample2.txt | AC | 3 ms
6,872 KB |
sample3.txt | AC | 3 ms
6,868 KB |
testcase01.txt | AC | 2 ms
6,872 KB |
testcase02.txt | AC | 3 ms
6,868 KB |
testcase03.txt | AC | 3 ms
8,916 KB |
testcase04.txt | AC | 2 ms
8,916 KB |
testcase05.txt | AC | 3 ms
6,872 KB |
testcase06.txt | AC | 3 ms
6,868 KB |
testcase07.txt | AC | 3 ms
6,872 KB |
testcase08.txt | AC | 3 ms
6,868 KB |
testcase09.txt | AC | 3 ms
8,916 KB |
testcase10.txt | AC | 2 ms
6,872 KB |
testcase11.txt | AC | 3 ms
6,872 KB |
testcase12.txt | AC | 3 ms
6,868 KB |
testcase13.txt | AC | 2 ms
6,872 KB |
testcase14.txt | AC | 2 ms
6,872 KB |
testcase15.txt | AC | 3 ms
6,872 KB |
testcase16.txt | AC | 2 ms
8,916 KB |
testcase17.txt | AC | 3 ms
8,916 KB |
testcase18.txt | AC | 3 ms
6,868 KB |
testcase19.txt | AC | 3 ms
6,868 KB |
testcase20.txt | AC | 2 ms
6,868 KB |
testcase21.txt | AC | 2 ms
6,868 KB |
testcase22.txt | AC | 3 ms
6,872 KB |
testcase23.txt | AC | 2 ms
6,868 KB |
testcase24.txt | AC | 2 ms
8,916 KB |
testcase25.txt | AC | 2 ms
6,868 KB |
testcase26.txt | AC | 2 ms
6,872 KB |
testcase27.txt | AC | 3 ms
6,872 KB |
testcase28.txt | AC | 2 ms
6,868 KB |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <string> #include <sstream> #include <cstring> #include <cstdio> #include <cstdlib> #include <cmath> #include <queue> #include <stack> #include <map> #include <set> #include <numeric> #include <cctype> #include <tuple> #include <array> #include <climits> #include <bitset> #include <cassert> #ifdef _MSC_VER #include <agents.h> #endif #define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i) #define rep(i, n) FOR(i, 0, n) #define ALL(v) v.begin(), v.end() #define REV(v) v.rbegin(), v.rend() #define MEMSET(v, s) memset(v, s, sizeof(v)) #define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end()) #define MP make_pair #define MT make_tuple using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> P; const int N = 110; int x[N], w[N], t[N]; int check(int i, int ct){ int k = ct / t[i]; if (k & 1) return (k+1)*t[i]; return t[i] - ct % t[i] >= w[i] ? ct : (k + 2)*t[i]; } int main(){ cin.tie(0); ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(20); int n, l; cin >> n >> l; rep(i, n) cin >> x[i] >> w[i] >> t[i]; x[n] = l; int ct = x[0]; rep(i, n){ ct = check(i, ct); ct += x[i + 1] - x[i]; } cout << ct << endl; }