Submission #40990

#TimeUsernameProblemLanguageResultExecution timeMemory
40990yusufakeTaxis (POI13_tak)C++98
20 / 100
182 ms48856 KiB
#include<bits/stdc++.h> using namespace std; #define _ int v, int tl, int tr, int l, int r, int h #define tm (tl+tr >> 1) #define sol v+v,tl,tm,l,r,h #define sag v+v+1,tm+1,tr,l,r,h #define mp make_pair #define pb push_back #define st first #define nd second typedef long long ll; typedef pair < int , int > pp; const int mod = 1e9 + 7; const int N = 5e5 + 5; ll A[N],m,d,n,i,j,x; int main(){ cin >> m >> d >> n; for(i=1;i<=n;i++) scanf("%lld", &A[i]); sort(A+1 , A+n+1); reverse(A+1 , A+n+1); if(A[1] < m-d) { cout << 0; return 0; } for(i=1;i<=n && A[i] >= m-d;i++){ x += A[i] - max(0LL , d - x); if(x >= m) { cout << i; return 0; } } i--; x = 0; for(j=1;j<i;j++){ x += A[j] - max(0LL , d - x); } for(j=i+1;j<=n;j++){ x += A[j] - max(0LL , d - x); if(x >= m-A[i]) { cout << j; return 0; } } cout << 0; return 0; }

Compilation message (stderr)

tak.cpp: In function 'int main()':
tak.cpp:25:40: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(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...