Submission #1602491
Source Code Expand
#include<iostream> #include<algorithm> #include<vector> #include<map> #include<queue> using namespace std; /* let's try computer shogi!!! */ struct hinge{ long long int s; // スタート long long int t; // 終わり long long int h; // 曲がるタイミング }; const long long int zero = 0; long long int X; long long int K; vector< long long int> r; vector<hinge> h; long long int Q; vector< long long int> t; vector< long long int> a; int main(){ cin >> X; cin >> K; r.resize(K); h.resize(K+1); h[0].s = zero; h[0].t = X; h[0].h = zero; for( long long int i=0;i<K;++i){ cin >> r[i]; } r.push_back(1145141919); cin >> Q; t.resize(Q); a.resize(Q); for( long long int i=0;i<Q;++i){ cin >> t[i]; cin >> a[i]; } long long int nt = 0; long long int qcnt = 0; for( long long int i=0;i<K+1;++i){ long long int dt = r[i] - nt; while(nt <= t[qcnt] && t[qcnt] <= r[i] && qcnt <Q){ long long int sand = ( a[qcnt] < h[i].h ? h[i].s : min(h[i].s + a[qcnt]-h[i].h, h[i].t)); if(i%2==0){ cout<<max(sand-(t[qcnt]-nt),zero)<<endl; }else{ cout<<min(X,sand+(t[qcnt]-nt))<<endl; } qcnt++; } if(i==K){continue;} cerr<<dt<<"(dt)"<<endl; if(i%2==0){ h[i+1].s = max(h[i].s - dt,zero); h[i+1].t = max(h[i].t - dt,zero); h[i+1].h = h[i].h + max(zero, (dt - h[i].s)); }else{ h[i+1].s = min(X,h[i].s + dt); h[i+1].t = min(X,h[i].t + dt); } cerr<<h[i+1].s<<","<<h[i+1].t<<","<<h[i+1].h<<"(sth)"<<endl; nt = r[i]; } }
Submission Info
Submission Time | |
---|---|
Task | F - Sandglass |
User | qhapaq_49 |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1682 Byte |
Status | WA |
Exec Time | 691 ms |
Memory | 7280 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 700 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt, 0_002.txt |
All | 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt, 1_021.txt, 1_022.txt, 1_023.txt, 1_024.txt, 1_025.txt, 1_026.txt, 1_027.txt, 1_028.txt, 1_029.txt, 1_030.txt, 1_031.txt, 1_032.txt, 1_033.txt, 1_034.txt, 1_035.txt, 1_036.txt, 1_037.txt, 1_038.txt, 1_039.txt, 1_040.txt, 1_041.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | AC | 1 ms | 256 KB |
0_001.txt | AC | 1 ms | 256 KB |
0_002.txt | WA | 1 ms | 256 KB |
1_003.txt | AC | 622 ms | 5104 KB |
1_004.txt | AC | 633 ms | 5104 KB |
1_005.txt | AC | 641 ms | 5104 KB |
1_006.txt | WA | 621 ms | 5104 KB |
1_007.txt | AC | 632 ms | 5232 KB |
1_008.txt | AC | 640 ms | 5232 KB |
1_009.txt | WA | 623 ms | 5232 KB |
1_010.txt | AC | 635 ms | 5232 KB |
1_011.txt | AC | 647 ms | 5232 KB |
1_012.txt | WA | 624 ms | 7152 KB |
1_013.txt | WA | 635 ms | 5360 KB |
1_014.txt | AC | 650 ms | 5232 KB |
1_015.txt | WA | 637 ms | 5360 KB |
1_016.txt | WA | 637 ms | 5360 KB |
1_017.txt | AC | 650 ms | 5360 KB |
1_018.txt | WA | 636 ms | 5488 KB |
1_019.txt | WA | 641 ms | 5488 KB |
1_020.txt | WA | 656 ms | 5488 KB |
1_021.txt | WA | 630 ms | 5488 KB |
1_022.txt | WA | 643 ms | 5616 KB |
1_023.txt | WA | 667 ms | 5616 KB |
1_024.txt | WA | 639 ms | 5488 KB |
1_025.txt | WA | 652 ms | 5744 KB |
1_026.txt | WA | 663 ms | 5744 KB |
1_027.txt | WA | 642 ms | 5488 KB |
1_028.txt | WA | 655 ms | 5488 KB |
1_029.txt | WA | 669 ms | 5744 KB |
1_030.txt | WA | 649 ms | 5488 KB |
1_031.txt | WA | 656 ms | 5488 KB |
1_032.txt | WA | 667 ms | 5872 KB |
1_033.txt | AC | 222 ms | 2688 KB |
1_034.txt | WA | 230 ms | 2688 KB |
1_035.txt | WA | 652 ms | 5748 KB |
1_036.txt | AC | 229 ms | 2688 KB |
1_037.txt | WA | 232 ms | 2688 KB |
1_038.txt | WA | 691 ms | 5744 KB |
1_039.txt | AC | 234 ms | 2432 KB |
1_040.txt | WA | 236 ms | 2816 KB |
1_041.txt | WA | 666 ms | 7280 KB |