제출 #82653

#제출 시각아이디문제언어결과실행 시간메모리
82653farukkastamonuda새로운 문제 (POI13_tak)C++14
100 / 100
199 ms12368 KiB
#include <bits/stdc++.h> #define fi first #define se second #define lo long long #define inf 1000000009 #define md 1000000007 #define li 500005 #define mp make_pair #define pb push_back using namespace std; int n,tut=1,kullan[li]; lo int m,d,A[li],sum; void fail(){ printf("0\n"); exit(0); } int main(){ scanf("%lld %lld %d",&m,&d,&n); sum=d; for(int i=1;i<=n;i++) scanf("%lld",&A[i]); sum=d; sort(A+1,A+n+1,greater<lo int>()); if(A[1]<m-d) fail(); for(int i=2;i<=n;i++){ if(A[i]>=m-d){ tut=i; } else break; } for(int i=1;i<=tut-1;i++) kullan[i]=1; for(int i=1;i<=n;i++){ if(i==tut) continue; if(kullan[i]==1){ if(A[i]<=sum) fail(); A[i]-=sum; lo int hop=sum; sum-=A[i]; if(sum<=0){ if(A[i]>=hop+m-d) printf("%d\n",i); else printf("%d\n",i+1); return 0; } } else{ if(A[i]<=sum){ if(A[tut]<=sum) fail(); A[tut]-=sum; lo int gg=sum; if(A[tut]>=gg+m-d){ printf("%d\n",i-1); return 0; } fail(); } A[i]-=sum; sum-=A[i]; if(sum<=0){ printf("%d\n",i); return 0; } } } A[tut]-=sum; lo int gg=sum; sum-=A[tut]; if(sum>0) fail(); if(A[tut]>=m-d+gg){ printf("%d\n",n); return 0; } fail(); return 0; }

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

tak.cpp: In function 'int main()':
tak.cpp:18:7: 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:20:29: 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("%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...