제출 #37081

#제출 시각아이디문제언어결과실행 시간메모리
37081szawinis새로운 문제 (POI13_tak)C++14
100 / 100
223 ms5920 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int N = 5e5+1; int n; ll m, d, x[N]; bool check(int lim_idx) { ll curr = 0; int rem = upper_bound(x+1, x+lim_idx+1, m - d, greater<ll>()) - x - 1; if(!rem) return false; for(int i = 1; i < rem && curr < d; i++) curr += max(x[i] - (d - curr), 0ll); for(int i = rem + 1; i <= lim_idx && curr < d; i++) curr += max(x[i] - (d - curr), 0ll); if(curr < d) return x[rem] - 2 * (d - curr) >= m - d; else return true; } int main() { scanf("%lld %lld %d", &m, &d, &n); for(int i = 1; i <= n; i++) scanf("%lld", x+i); sort(x+1, x+n+1, greater<ll>()); int l = 1, r = n; while(l < r) { int mid = l+r >> 1; if(check(mid)) r = mid; else l = mid+1; } if(!check(l)) printf("0"); else printf("%d", l); }

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

tak.cpp: In function 'int main()':
tak.cpp:27:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int mid = l+r >> 1;
              ^
tak.cpp:22:35: 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:23:48: 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", x+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...