제출 #978219

#제출 시각아이디문제언어결과실행 시간메모리
978219sleepntsheepFish 3 (JOI24_fish3)C++17
7 / 100
133 ms11604 KiB
long long lo(long long a,long long b){return a<b?a:b;} #include<stdio.h> #include<assert.h> #include<string.h> #define N 300005 int n,q; long long d,c[N],t[N],b[N],pc[N],bo; int find(int p) { int l=0,r=bo-1,z=-1; while(l<=r) { int o=(l+r)/2; if(b[o]<=p)l=o+1,z=o; else r=o-1; } if(z==-1)return -1; return b[z]; } int main() { scanf("%d%lld",&n,&d); for(int i=1;i<=n;++i) { scanf("%lld",c+i),pc[i]=pc[i-1]+c[i]; if(!c[i])b[bo++]=i; } scanf("%d",&q); for(int l,r,i=0;i<q;++i) { scanf("%d%d",&l,&r); int zero=find(r); if(zero==-1||zero<l)zero=l-1; int ones=pc[zero]-pc[l-1]; if(d==1) { printf("%d\n",ones); } else { if(ones)puts("-1"); else puts("0"); } } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'int main()':
Main.cpp:25:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   25 |     scanf("%d%lld",&n,&d);
      |     ~~~~~^~~~~~~~~~~~~~~~
Main.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         scanf("%lld",c+i),pc[i]=pc[i-1]+c[i];
      |         ~~~~~^~~~~~~~~~~~
Main.cpp:32:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     scanf("%d",&q);
      |     ~~~~~^~~~~~~~~
Main.cpp:36:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |         scanf("%d%d",&l,&r);
      |         ~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...