Submission #2874356
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MAX=505000;
const ll INF=0x3f3f3f3f3f3f3f;
ll p,q,tmp[MAX],ans[MAX],d[MAX],dtot[MAX],near[MAX],N,D,Q;
int main(){
scanf("%lld%lld",&N,&D);
for(ll i=0;i<N;i++) scanf("%lld",&d[i]);
dtot[0]=D;
for(ll i=1;i<=N;i++) dtot[i]=min(dtot[i-1],abs(d[i-1]-dtot[i-1]));
near[N]=0;
for(ll i=N-1;i>=1;i--) {
if(near[i+1]*2+1>=d[i]) near[i]=d[i]+near[i+1];
else near[i]=near[i+1];
}
for(ll i=0;i<N;i++) {
if(near[i+1]>=dtot[i]) ans[i]=1;
//printf("%lld %lld %lld\n",i,dtot[i],near[i+1]);
}
scanf("%lld",&Q);
for(ll i=0;i<Q;i++){
ll t1;
scanf("%lld",&t1);
if(ans[t1-1]) printf("NO\n");
else printf("YES\n");
}
return 0;
}
Submission Info
Submission Time |
|
Task |
E - Alice in linear land |
User |
x0000ai |
Language |
C++14 (GCC 5.4.1) |
Score |
900 |
Code Size |
888 Byte |
Status |
AC |
Exec Time |
122 ms |
Memory |
18304 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:12:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld%lld",&N,&D);
^
./Main.cpp:13:44: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
for(ll i=0;i<N;i++) scanf("%lld",&d[i]);
^
./Main.cpp:26:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&Q);
^
./Main.cpp:29:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&t1);
^
Judge Result
Set Name |
Sample |
All |
Score / Max Score |
0 / 0 |
900 / 900 |
Status |
|
|
Set Name |
Test Cases |
Sample |
00-00.txt, 00-01.txt, 00-02.txt |
All |
00-00.txt, 00-01.txt, 00-02.txt, 01-00.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt |
Case Name |
Status |
Exec Time |
Memory |
00-00.txt |
AC |
2 ms |
6400 KB |
00-01.txt |
AC |
2 ms |
4352 KB |
00-02.txt |
AC |
2 ms |
6400 KB |
01-00.txt |
AC |
2 ms |
6400 KB |
01-01.txt |
AC |
2 ms |
6400 KB |
01-02.txt |
AC |
121 ms |
18304 KB |
01-03.txt |
AC |
120 ms |
18176 KB |
01-04.txt |
AC |
122 ms |
18304 KB |
01-05.txt |
AC |
119 ms |
18304 KB |
01-06.txt |
AC |
121 ms |
18304 KB |
01-07.txt |
AC |
122 ms |
18304 KB |
01-08.txt |
AC |
117 ms |
18048 KB |
01-09.txt |
AC |
118 ms |
18048 KB |
01-10.txt |
AC |
119 ms |
18048 KB |