제출 #28987

#제출 시각아이디문제언어결과실행 시간메모리
28987tlwpdus새로운 문제 (POI13_tak)C++11
100 / 100
196 ms5924 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll m, d; int n; ll x[500100]; int main() { int i; scanf("%lld%lld%d",&m,&d,&n); m*=2; d*=2; for (i=0;i<n;i++) {scanf("%lld",&x[i]);x[i]*=2;} sort(x,x+n); int idx = lower_bound(x,x+n,m-d)-x; if (idx==n) { printf("0\n"); return 0; } ll loc = (d-(x[idx]-(m-d))/2), cur = 0; int cnt = 0; for (i=n-1;i>=0;i--) { if (cur>=m) { printf("%d\n",cnt); return 0; } if (cur>=loc) { printf("%d\n",cnt+1); return 0; } if (i==idx) continue; if (d-cur>=x[i]) { printf("0\n"); return 0; } cur += (x[i]-(d-cur)); cnt++; } if (cur>=m) { printf("%d\n",cnt); return 0; } if (cur>=loc) { printf("%d\n",cnt+1); return 0; } printf("0\n"); return 0; }

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

tak.cpp: In function 'int main()':
tak.cpp:13:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld%d",&m,&d,&n); m*=2; d*=2;
                              ^
tak.cpp:14:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for (i=0;i<n;i++) {scanf("%lld",&x[i]);x[i]*=2;}
                                        ^
#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...