Submission #02272
ソースコード
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 50 51 52 53 54 55 56 | #include<bits/stdc++.h> using namespace std; long long int n,t,k; long long int A[100010],D[100010]; vector< long long int > gp,gm; long long int pos[100010]; int main(){ cin >> n >> t >> k; gp.push_back(-8000000000000000000LL); gm.push_back(-8000000000000000000LL); for ( int i=0;i<n;i++){ cin >> A[i] >> D[i]; if (D[i] == 1ll) gp.push_back(A[i]); else gm.push_back(A[i]); } gp.push_back(8000000000000000000LL); gm.push_back(8000000000000000000LL); for ( int i=0;i<k;i++){ long long int a; cin >> a; a--; if (D[a] == 1ll){ vector< long long int >::iterator it = lower_bound(gm.begin(),gm.end(),A[a]); if (it == gm.end() - 1){ cout << A[a] + t << endl; } else { vector< long long int >::iterator S = lower_bound(gp.begin(),gp.end(),*it); S--; long long int pos = (*it + *S) / 2LL; if (A[a] + t <= pos){ cout << A[a] + t << endl; } else { cout << pos << endl; } } } else { vector< long long int >::iterator it = lower_bound(gp.begin(),gp.end(),A[a]); it--; if (it == gp.begin()){ cout << A[a] - t << endl; } else { vector< long long int >::iterator S = lower_bound(gm.begin(),gm.end(),*it); long long int pos = (*it + *S) / 2LL; if (A[a] - t >= pos){ cout << A[a] - t << endl; } else { cout << pos << endl; } } } } } |
ステータス
項目 | データ |
---|---|
問題 | 0260 - JOI国のお散歩事情 (Walking in JOI Kingdom) |
ユーザー名 | ei1428 |
投稿日時 | 2015-12-14 15:25:14 |
言語 | C++11 |
状態 | Accepted |
得点 | 5 |
ソースコード長 | 1398 Byte |
最大実行時間 | 83 ms |
最大メモリ使用量 | 3264 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 | 11 ms | 476 KB |
1
|
||||
2016-yo-t4-in2.txt | AC | 17 ms | 560 KB |
2
|
||||
2016-yo-t4-in3.txt | AC | 59 ms | 2916 KB |
3
|
||||
2016-yo-t4-in4.txt | AC | 83 ms | 3220 KB |
4
|
||||
2016-yo-t4-in5.txt | AC | 81 ms | 3264 KB |
5
|
||||
2016-yo-t4-in_s1.txt | AC | 11 ms | 544 KB | |||||
2016-yo-t4-in_s2.txt | AC | 10 ms | 384 KB |