Submission #1995963
Source Code Expand
#include<bits/stdc++.h>
#define L long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
#define aa first
#define bb second
#define mp make_pair
#define mpp(a,b,c) mp(mp(a,b),c)
using namespace std;
int n,m,q,x[100010],a,b,c,t;
inline void orz(int t,int k)
{
if(k==1)
{
c+=t;
if(b+c>m)
b=m-c;
if(a>b)
a=b=0,c=m;
}
else
{
c-=t;
if(a+c<0)
a=-c;
if(a>b)
a=b=c=0;
}
}
int main()
{
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
int i,j,k,l;
scanf("%d%d",&m,&n);
for(i=1;i<=n;i++)
scanf("%d",&x[i]);
b=m;
k=1;
l=-1;
scanf("%d",&q);
while(q--)
{
scanf("%d%d",&i,&j);
while(k<=n && i>=x[k])
{
orz(x[k]-t,l);
t=x[k];
l*=-1;
k++;
}
orz(i-t,l);
t=i;
if(j<=a)
printf("%d\n",a+c);
else if(j<=b)
printf("%d\n",j+c);
else
printf("%d\n",b+c);
}
return 0;
}
Submission Info
| Submission Time |
|
| Task |
F - Sandglass |
| User |
fateice |
| Language |
C++14 (GCC 5.4.1) |
| Score |
700 |
| Code Size |
1003 Byte |
| Status |
AC |
| Exec Time |
46 ms |
| Memory |
1536 KiB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:36:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&m,&n);
^
./Main.cpp:38:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&x[i]);
^
./Main.cpp:42:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&q);
^
./Main.cpp:45:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&i,&j);
^
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
700 / 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 KiB |
| 0_001.txt |
AC |
1 ms |
256 KiB |
| 0_002.txt |
AC |
1 ms |
256 KiB |
| 1_003.txt |
AC |
37 ms |
896 KiB |
| 1_004.txt |
AC |
38 ms |
768 KiB |
| 1_005.txt |
AC |
40 ms |
768 KiB |
| 1_006.txt |
AC |
36 ms |
896 KiB |
| 1_007.txt |
AC |
38 ms |
896 KiB |
| 1_008.txt |
AC |
40 ms |
896 KiB |
| 1_009.txt |
AC |
38 ms |
1024 KiB |
| 1_010.txt |
AC |
39 ms |
896 KiB |
| 1_011.txt |
AC |
41 ms |
896 KiB |
| 1_012.txt |
AC |
38 ms |
1024 KiB |
| 1_013.txt |
AC |
39 ms |
1024 KiB |
| 1_014.txt |
AC |
41 ms |
1024 KiB |
| 1_015.txt |
AC |
38 ms |
1152 KiB |
| 1_016.txt |
AC |
40 ms |
1152 KiB |
| 1_017.txt |
AC |
42 ms |
1024 KiB |
| 1_018.txt |
AC |
39 ms |
1152 KiB |
| 1_019.txt |
AC |
43 ms |
1152 KiB |
| 1_020.txt |
AC |
43 ms |
1152 KiB |
| 1_021.txt |
AC |
39 ms |
1152 KiB |
| 1_022.txt |
AC |
41 ms |
1280 KiB |
| 1_023.txt |
AC |
43 ms |
1280 KiB |
| 1_024.txt |
AC |
39 ms |
1152 KiB |
| 1_025.txt |
AC |
42 ms |
1408 KiB |
| 1_026.txt |
AC |
44 ms |
1408 KiB |
| 1_027.txt |
AC |
41 ms |
1152 KiB |
| 1_028.txt |
AC |
42 ms |
1280 KiB |
| 1_029.txt |
AC |
45 ms |
1536 KiB |
| 1_030.txt |
AC |
42 ms |
1152 KiB |
| 1_031.txt |
AC |
43 ms |
1152 KiB |
| 1_032.txt |
AC |
46 ms |
1536 KiB |
| 1_033.txt |
AC |
31 ms |
1024 KiB |
| 1_034.txt |
AC |
33 ms |
1024 KiB |
| 1_035.txt |
AC |
43 ms |
1408 KiB |
| 1_036.txt |
AC |
32 ms |
1152 KiB |
| 1_037.txt |
AC |
32 ms |
1152 KiB |
| 1_038.txt |
AC |
44 ms |
1536 KiB |
| 1_039.txt |
AC |
32 ms |
896 KiB |
| 1_040.txt |
AC |
33 ms |
1280 KiB |
| 1_041.txt |
AC |
46 ms |
1536 KiB |