제출 #28970

#제출 시각아이디문제언어결과실행 시간메모리
28970khsoo01새로운 문제 (POI13_tak)C++11
100 / 100
213 ms5924 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; const ll N = 500005; ll m, d, n, a[N]; int main() { scanf("%lld%lld%lld",&m,&d,&n); for(ll i=1;i<=n;i++) { scanf("%lld",&a[i]); } sort(a+1, a+1+n); ll C = 0, V = 0, X = 0; for(ll i=n;i>=1;i--) { if(a[i] - abs(d-C) > 0) { C += a[i] - abs(d-C); V++; } if(C >= m) { printf("%lld\n", V); return 0; } } C = 0; V = 0; bool flag = false; for(ll i=0;i<=n;i++) { if(a[i] >= m-d) { X = a[i]; a[i] = 0; if(!i) V--; flag = true; break; } } if(!flag) {puts("0"); return 0;} for(ll i=n;C<d && i>=1;i--) { if(a[i] - abs(d-C) > 0) { C += a[i] - abs(d-C); V++; } if(C + max(0ll, X-abs(d-C)) >= m) { printf("%lld\n", V+1); return 0; } } puts("0"); }

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

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