Submission #02334
ソースコード
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 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | /*#include<bits/stdc++.h> using namespace std; typedef struct{ long long int stay; int hou; long long int kyori; }P; int main(){ int n,q; long long int t; P per[100000]; int nhou=1; int oha; cin>>n>>t>>q; for(int i=0;i<n;i++){ cin>>per[i].stay>>per[i].hou; per[i].kyori=100000000000000000LL; } for(int i=0;i<n;i++){ if(per[i].hou==1 && per[i+1].hou==2){ oha=(per[i].stay+per[i+1].stay)/2; per[i].kyori=oha; per[i+1].kyori=oha; for(int j=i-1;j>=0;j--){ if(per[j].hou==1){ per[j].kyori=oha; } else break; } for(int j=i+2;j<n;j++){ if(per[j].hou==2){ per[j].kyori=oha; } else if(per[j].hou==1){ i=j; break; } } } } for(int i=0,a;i<q;i++){ cin>>a; if(per[a-1].kyori > t || per[a-1].kyori==100000000000000000LL){ if(per[a-1].hou==1){ cout<<per[a-1].stay+t<<endl; } else cout<<per[a-1].stay-t<<endl; } else cout<<per[a-1].kyori<<endl; } } */ #include <stdio.h> long long dat[100010]; long long vec[100010][2]; int main() { int num,query,i,j,z,zb; long long t,tt,za; i=0; scanf ( "%d%lld%d" ,&num,&t,&query); vec[0][0]=-3000000000000000000LL; vec[0][1]=1; for (;i<num;i++){ scanf ( "%lld%d" ,&za,&zb); vec[i+1][0]=za; vec[i+1][1]=zb; } vec[num+1][0]=3000000000000000000LL; vec[num+1][1]=2; i=0; for (;i<=num;i++){ if (vec[i][1]==1&&vec[i+1][1]==2){ tt=(vec[i][0]+vec[i+1][0])/2; j=i; for (;j>=0;j--){ if (vec[j][1]==1)dat[j]=tt; else break ; } j=i+1; for (;j<num+2;j++){ if (vec[j][1]==2)dat[j]=tt; else break ; } } } i=0; for (;i<query;i++){ scanf ( "%d" ,&z); if (vec[z][1]==1){ printf ( "%lld\n" ,(vec[z][0]+t<dat[z])?(vec[z][0]+t):(dat[z])); } else { printf ( "%lld\n" ,(vec[z][0]-t<dat[z])?(dat[z]):(vec[z][0]-t)); } } return 0; } |
ステータス
項目 | データ |
---|---|
問題 | 0260 - JOI国のお散歩事情 (Walking in JOI Kingdom) |
ユーザー名 | ei1501 |
投稿日時 | 2015-12-15 17:47:00 |
言語 | C++11 |
状態 | Accepted |
得点 | 5 |
ソースコード長 | 1970 Byte |
最大実行時間 | 39 ms |
最大メモリ使用量 | 2892 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 | 20 ms | 472 KB |
1
|
||||
2016-yo-t4-in2.txt | AC | 19 ms | 580 KB |
2
|
||||
2016-yo-t4-in3.txt | AC | 28 ms | 2744 KB |
3
|
||||
2016-yo-t4-in4.txt | AC | 29 ms | 2816 KB |
4
|
||||
2016-yo-t4-in5.txt | AC | 39 ms | 2892 KB |
5
|
||||
2016-yo-t4-in_s1.txt | AC | 18 ms | 540 KB | |||||
2016-yo-t4-in_s2.txt | AC | 17 ms | 520 KB |