제출 #36605

#제출 시각아이디문제언어결과실행 시간메모리
36605Flumen새로운 문제 (POI13_tak)C++11
10 / 100
196 ms9828 KiB
#include<bits/stdc++.h> using namespace std; long long a[500100],v[500100]; int main(){ int n,ans=600000,num,i,l,r,mid; long long m,d,tmp,tmp1,x; scanf("%lld%lld%d",&m,&d,&n); for(i=1;i<=n;i++){ scanf("%lld",&a[i]); a[i]*=-1; } sort(a+1,a+n+1); for(i=1;i<=n;i++)a[i]*=-1; num=1; tmp=0; while(tmp<d){ num++; tmp1=tmp; tmp*=2; tmp+=(a[num]-d); if(tmp<=tmp1){ num--; break; } } //printf("%d\n",num); for(i=1;i<=num;i++){ v[i]=v[i-1]*2+(a[i]-d); //printf("%lld\n",v[i]); } for(i=n;i>=1;i--){ if(a[i]<m-d)continue; l=0;r=num; while(l<r){ mid=(l+r)/2; //printf("%d %d\n",i,mid); if(i>mid){ if(v[mid]>=d-((a[i]-m+d)/2))r=mid; else l=mid+1; } else{ if(l==0)x=0; else x=v[i-1]*(1<<(mid-i))+v[mid]-v[i]*(1<<(mid-i)); if(x>=d-((a[i]-m+d)/2))r=mid; else l=mid+1; } } if(l<i){ if(v[l]>=d-((a[i]-m+d)/2))ans=min(ans,l+1); } else{ x=v[i-1]*(1<<(l-i))+v[l]-v[i]*(1<<(l-i)); if(x>=d-((a[i]-m+d)/2))ans=min(ans,l); } //printf("%d %d\n",i,l); } if(ans==600000)ans=0; printf("%d",ans); return 0; }

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

tak.cpp: In function 'int main()':
tak.cpp:7:33: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld%d",&m,&d,&n);
                                 ^
tak.cpp:9:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&a[i]);
                            ^
#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...
#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...