Contest Duration: - (local time) (100 minutes) Back to Home

Submission #857020

Source Code Expand

Copy
```#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <queue>
#define INF 0x3f3f3f3f
#define ll long long
using namespace std;
#define mod 100000000
int mark[200000],flag[200000],a[200000];
int main()
{
int n,l,q,x,y;
while(~scanf("%d",&n))
{
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
scanf("%d",&l);
int res=1,sum=0;
for(int i=1,j;i<=n;)
{
sum=0;
for(j=i;j<=n;j++)
{
sum+=a[j]-a[j-1];
if(sum>l) break;
}
for(int k=i;k<j;k++) mark[k]=res,flag[k]=j-1;
//  cout<<j<<endl;
res++;i=j;
}
scanf("%d",&q);
while(q--)
{
scanf("%d%d",&x,&y);
if(x>y) swap(x,y);
if(flag[x]==x)
{
cout<<mark[y]-mark[x]<<endl;
}
else
{
int sum=0,res=1,ans=-1;
for(int i=x;i<=y;i++)
{
sum+=a[i]-a[i-1];
if(sum>l)
{
if(flag[i-1]==i-1) ans=res+mark[y]-mark[i-1];
else res++;
sum=0;
}
if(ans!=-1) break;
//  cout<<i<<" "<<res<<endl;
}
if(ans==-1) ans=res;
cout<<ans<<endl;
}
}
}
return 0;
}
```

#### Submission Info

Submission Time 2016-08-28 22:33:30+0900 E - Tak and Hotels mirac1e C++14 (GCC 5.4.1) 0 1648 Byte WA 3153 ms 2048 KB

#### Compile Error

```./Main.cpp: In function ‘int main()’:
./Main.cpp:23:47: 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",&a[i]);
^
./Main.cpp:24:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&l);
^
./Main.cpp:38:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&q);
^
./Main.cpp:41:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d",&x,&y);
^
```

#### Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 0 / 200 0 / 500
Status
 AC × 1
 AC × 5 WA × 9
 AC × 7 WA × 17 TLE × 3
Set Name Test Cases
Sample example_01.txt
Case Name Status Exec Time Memory
example_01.txt AC 4 ms 256 KB
subtask1_01.txt WA 4 ms 256 KB
subtask1_02.txt AC 4 ms 256 KB
subtask1_03.txt WA 10 ms 256 KB
subtask1_04.txt AC 11 ms 256 KB
subtask1_05.txt WA 11 ms 256 KB
subtask1_06.txt AC 7 ms 256 KB
subtask1_07.txt WA 7 ms 256 KB
subtask1_08.txt AC 11 ms 256 KB
subtask1_09.txt WA 12 ms 256 KB
subtask1_10.txt WA 10 ms 256 KB
subtask1_11.txt WA 10 ms 256 KB
subtask1_12.txt WA 11 ms 256 KB
subtask1_13.txt WA 11 ms 256 KB
subtask2_01.txt WA 738 ms 1920 KB
subtask2_02.txt AC 685 ms 2048 KB
subtask2_03.txt WA 1492 ms 1792 KB
subtask2_04.txt TLE 3062 ms 1152 KB
subtask2_05.txt WA 466 ms 1280 KB
subtask2_06.txt TLE 3153 ms 1536 KB
subtask2_07.txt WA 701 ms 1920 KB
subtask2_08.txt WA 816 ms 1920 KB
subtask2_09.txt WA 755 ms 1920 KB
subtask2_10.txt WA 689 ms 1920 KB
subtask2_11.txt WA 676 ms 1920 KB
subtask2_12.txt AC 699 ms 2048 KB
subtask2_13.txt TLE 3153 ms 1536 KB