Submission #1595117


Source Code Expand

#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main(){
  int X, K, Q;
  int r[100010];
  cin >> X;
  cin >> K;
  for(int i = 0; i < K; i++)  cin >> r[i];
  cin >> Q;

  int x, y, z;
  int t, a;
  int tim = 0, dir = 1, rin = 0;
  x = 0; y = X; z = 0;
  for(int i = 0; i < Q; i++){
    cin >> t >> a;
    for(int j = tim; j < t; j++){
      if(j == r[rin]){
        dir = 1 - dir;
        rin++;
      }
      if(dir == 1){
        z = max(z-1, -X);
        x = max(x, -z);
      }
      else{
        z = min(z+1, X);
        y = min(y, X-z);
      }
    }
    tim = t;

    if(a <= x)  cout << max(0, min(x + z, X)) << endl;
    else if(a >= y) cout << max(0, min(y + z, X)) << endl;
    else  cout << max(0, min(a + z, X)) << endl;

    //cout << x << " " << y << " " << z << endl;

  }

  return 0;
}

Submission Info

Submission Time
Task F - Sandglass
User bomac1
Language C++14 (GCC 5.4.1)
Score 0
Code Size 884 Byte
Status WA
Exec Time 2078 ms
Memory 1664 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 700
Status
AC × 3
AC × 18
WA × 11
TLE × 13
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 AC 1 ms 256 KB
1_003.txt WA 269 ms 768 KB
1_004.txt WA 293 ms 768 KB
1_005.txt TLE 2019 ms 768 KB
1_006.txt WA 257 ms 896 KB
1_007.txt WA 284 ms 896 KB
1_008.txt TLE 2001 ms 896 KB
1_009.txt WA 257 ms 896 KB
1_010.txt WA 301 ms 896 KB
1_011.txt TLE 2011 ms 896 KB
1_012.txt AC 264 ms 1024 KB
1_013.txt WA 298 ms 1024 KB
1_014.txt TLE 2014 ms 1024 KB
1_015.txt AC 267 ms 1152 KB
1_016.txt WA 305 ms 1152 KB
1_017.txt TLE 2020 ms 1152 KB
1_018.txt AC 277 ms 1152 KB
1_019.txt AC 306 ms 1152 KB
1_020.txt TLE 2023 ms 1280 KB
1_021.txt AC 284 ms 1152 KB
1_022.txt AC 308 ms 1280 KB
1_023.txt TLE 2037 ms 1280 KB
1_024.txt WA 307 ms 1280 KB
1_025.txt AC 309 ms 1408 KB
1_026.txt TLE 2037 ms 1408 KB
1_027.txt WA 469 ms 1536 KB
1_028.txt AC 481 ms 1280 KB
1_029.txt TLE 2036 ms 1536 KB
1_030.txt WA 1984 ms 1664 KB
1_031.txt TLE 2078 ms 1152 KB
1_032.txt TLE 2044 ms 1536 KB
1_033.txt AC 283 ms 1024 KB
1_034.txt AC 287 ms 1024 KB
1_035.txt AC 334 ms 1408 KB
1_036.txt AC 601 ms 1152 KB
1_037.txt AC 604 ms 1152 KB
1_038.txt AC 662 ms 1536 KB
1_039.txt TLE 2027 ms 896 KB
1_040.txt AC 1987 ms 1280 KB
1_041.txt TLE 2046 ms 1536 KB