Submission #45533


ソースコード

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
#include<bits/stdc++.h>
using namespace std;
#define INF 3000000000000000009LL
vector<long long>p;
int main(){
long long n,t,q;
long long a[100009],d[100009];
cin>>n>>t>>q;
for(int i=0;i<n;i++){
cin>>a[i]>>d[i];
}
p.push_back(-INF);
for(int i=0;i<n-1;i++){
if(d[i]==1&&d[i+1]==2){
p.push_back((a[i+1]+a[i])/2);
}
}
p.push_back(INF);
for(int i=0;i<q;i++){
long long x,ans;
cin>>x;
long long idx=upper_bound(p.begin(),p.end(),a[x-1])-p.begin();
if(d[x-1]==1){
ans=min(a[x-1]+t,p[idx]);
}
else{
ans=max(a[x-1]-t,p[idx-1]);
}
cout<<ans<<endl;
}
return(0);
}

ステータス

項目 データ
問題 0260 - JOI国のお散歩事情 (Walking in JOI Kingdom)
ユーザー名 r1705
投稿日時 2018-12-07 18:43:10
言語 C++11
状態 Accepted
得点 5
ソースコード長 674 Byte
最大実行時間 77 ms
最大メモリ使用量 2520 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 25 ms 604 KB
1
2016-yo-t4-in2.txt AC 26 ms 560 KB
2
2016-yo-t4-in3.txt AC 58 ms 2108 KB
3
2016-yo-t4-in4.txt AC 77 ms 2056 KB
4
2016-yo-t4-in5.txt AC 75 ms 2520 KB
5
2016-yo-t4-in_s1.txt AC 22 ms 608 KB
2016-yo-t4-in_s2.txt AC 19 ms 560 KB