Submission #02226
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | #include<bits/stdc++.h> using namespace std; typedef long long int64; const int INF = 1 << 30; int main() { int64 N, T, Q; vector< int64 > GoPlus, GoMinus; int64 A[100000], B[100000]; cin >> N >> T >> Q; GoPlus.push_back(-3000000000000000000LL); for ( int i = 0; i < N; i++) { cin >> A[i] >> B[i]; if (B[i] == 1LL) GoPlus.push_back(A[i]); else GoMinus.push_back(A[i]); } GoMinus.push_back(3000000000000000000LL); for ( int i = 0; i < Q; i++) { int64 X; cin >> X; --X; if (B[X] == 1LL) { vector< int64 >::iterator it = lower_bound(GoMinus.begin(), GoMinus.end(), A[X]); vector< int64 >::iterator STOP = --lower_bound(GoPlus.begin(), GoPlus.end(), *it); int64 POS = (*it + *STOP) / 2LL; if (A[X] + T <= POS) { cout << A[X] + T << endl; } else { cout << POS << endl; } } else { vector< int64 >::iterator it = --lower_bound(GoPlus.begin(), GoPlus.end(), A[X]); vector< int64 >::iterator STOP = lower_bound(GoMinus.begin(), GoMinus.end(), *it); int64 POS = (*STOP + *it) / 2LL; if (A[X] - T >= POS) { cout << A[X] - T << endl; } else { cout << POS << endl; } } } } |
ステータス
項目 | データ |
---|---|
問題 | 0260 - JOI国のお散歩事情 (Walking in JOI Kingdom) |
ユーザー名 | ei1333 |
投稿日時 | 2015-12-14 00:20:56 |
言語 | C++11 |
状態 | Accepted |
得点 | 5 |
ソースコード長 | 1279 Byte |
最大実行時間 | 84 ms |
最大メモリ使用量 | 3112 KB |
セット
セット | 得点 | Cases | |
---|---|---|---|
1 | INPUT1 | 1 / 1 | *in1.txt |
2 | INPUT2 | 1 / 1 | *in2.txt |
3 | INPUT3 | 1 / 1 | *in3.txt |
4 | INPUT4 | 1 / 1 | *in4.txt |
5 | INPUT5 | 1 / 1 | *in5.txt |
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # | ||||
---|---|---|---|---|---|---|---|---|
2016-yo-t4-in1.txt | AC | 24 ms | 476 KB |
1
|
||||
2016-yo-t4-in2.txt | AC | 15 ms | 568 KB |
2
|
||||
2016-yo-t4-in3.txt | AC | 59 ms | 2936 KB |
3
|
||||
2016-yo-t4-in4.txt | AC | 84 ms | 3112 KB |
4
|
||||
2016-yo-t4-in5.txt | AC | 80 ms | 3032 KB |
5
|
||||
2016-yo-t4-in_s1.txt | AC | 14 ms | 576 KB | |||||
2016-yo-t4-in_s2.txt | AC | 10 ms | 676 KB |