제출 #29467

#제출 시각아이디문제언어결과실행 시간메모리
29467kdh9949새로운 문제 (POI13_tak)C++14
0 / 100
199 ms5924 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, t, cnt, ans; ll d, b, x, a[500010]; int main(){ scanf("%lld%lld%d", &d, &b, &n); for(int i = 0; i < n; i++) scanf("%lld", a + i); ans = n + 1; sort(a, a + n, greater<int>()); for(int i = 0; i < n; i++){ if(x <= b) x += max(0LL, a[i] - (b - x)); else x = max(x, b + a[i]); cnt++; if(x >= d){ ans = min(ans, cnt); break; } } for(; t < n && a[t] >= d - b; t++); t--; cnt = 0; for(int i = 0; i < n; i++){ if(i == t) continue; if(x <= b) x += max(0LL, a[i] - (b - x)); else x = max(x, b + a[i]); cnt++; if(x >= d){ ans = min(ans, cnt); break; } if(a[t] >= max(d - b, b + d - 2 * x)){ ans = min(ans, cnt + 1); break; } } printf("%d\n", ans % (n + 1)); }

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

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