Submission #1751859
Source Code Expand
#include<bits/stdc++.h> using namespace std; #define MN 100005 int t,r[MN],a,v[MN],x,n,q; int main(){ cin>>x>>n; for(int i=1;i<=n;++i)scanf("%d",r+i); for(int i=1;i<=n;++i)v[i]=r[i]-r[i-1]; cin>>q;int tl=0,h=x,l=0,hv=x,lv=0;v[n+1]=1000000008; while(q--){ scanf("%d%d",&t,&a); while(r[tl+1]<=t){ if((++tl)&1){ if(lv<v[tl])l+=v[tl]-lv; hv=max(0,hv-v[tl]); lv=max(0,lv-v[tl]); }else{ if(hv+v[tl]>x)h-=v[tl]+hv-x; hv=min(x,hv+v[tl]); lv=min(x,lv+v[tl]); } h=max(0,h);l=min(l,x); }t-=r[tl]; if(l>=a)a=lv;else if(h<=a)a=hv;else a+=lv-l; if(tl&1)printf("%d\n",min(x,a+t));else printf("%d\n",max(0,a-t)); } return 0; }
Submission Info
Submission Time | |
---|---|
Task | F - Sandglass |
User | tenecnt |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 690 Byte |
Status | RE |
Exec Time | 144 ms |
Memory | 2048 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:7:38: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] for(int i=1;i<=n;++i)scanf("%d",r+i); ^ ./Main.cpp:11:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d",&t,&a); ^
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 | RE | 97 ms | 256 KB |
0_001.txt | AC | 1 ms | 256 KB |
0_002.txt | RE | 96 ms | 256 KB |
1_003.txt | RE | 132 ms | 1152 KB |
1_004.txt | AC | 38 ms | 1152 KB |
1_005.txt | RE | 135 ms | 1152 KB |
1_006.txt | RE | 131 ms | 1280 KB |
1_007.txt | AC | 38 ms | 1280 KB |
1_008.txt | RE | 135 ms | 1280 KB |
1_009.txt | RE | 132 ms | 1280 KB |
1_010.txt | RE | 133 ms | 1280 KB |
1_011.txt | RE | 137 ms | 1408 KB |
1_012.txt | RE | 132 ms | 1408 KB |
1_013.txt | AC | 39 ms | 1408 KB |
1_014.txt | RE | 135 ms | 1408 KB |
1_015.txt | AC | 38 ms | 1536 KB |
1_016.txt | RE | 134 ms | 1536 KB |
1_017.txt | AC | 42 ms | 1408 KB |
1_018.txt | RE | 133 ms | 1536 KB |
1_019.txt | RE | 135 ms | 1536 KB |
1_020.txt | RE | 138 ms | 1536 KB |
1_021.txt | RE | 111 ms | 1152 KB |
1_022.txt | AC | 42 ms | 1664 KB |
1_023.txt | RE | 138 ms | 1664 KB |
1_024.txt | RE | 106 ms | 1024 KB |
1_025.txt | AC | 42 ms | 1792 KB |
1_026.txt | RE | 138 ms | 1792 KB |
1_027.txt | RE | 105 ms | 1024 KB |
1_028.txt | RE | 109 ms | 1152 KB |
1_029.txt | RE | 144 ms | 1920 KB |
1_030.txt | RE | 106 ms | 1024 KB |
1_031.txt | RE | 106 ms | 1024 KB |
1_032.txt | RE | 140 ms | 2048 KB |
1_033.txt | RE | 99 ms | 256 KB |
1_034.txt | RE | 126 ms | 1024 KB |
1_035.txt | AC | 43 ms | 1792 KB |
1_036.txt | RE | 102 ms | 384 KB |
1_037.txt | RE | 128 ms | 1152 KB |
1_038.txt | RE | 140 ms | 1920 KB |
1_039.txt | RE | 127 ms | 768 KB |
1_040.txt | RE | 128 ms | 1280 KB |
1_041.txt | RE | 140 ms | 2048 KB |