Submission #36597

#TimeUsernameProblemLanguageResultExecution timeMemory
36597WhipppedCreamTaxis (POI13_tak)C++14
50 / 100
193 ms5920 KiB
#include <bits/stdc++.h> //#ifdef atom #else #endif using namespace std; typedef long long ll; typedef pair<int, int> ii; #define X first #define Y second #define vi vector<int> #define vvi vector< vi > #define vii vector< ii > #define mp make_pair #define pb push_back const int maxn = 5e5+5; ll x[maxn]; int n; ll d, m; int LU(ll k) { return lower_bound(x, x+n, k)-x; } void fail() { puts("0"); exit(0); } void use(ll x) { int dd = min(d, x-d); d -= dd; m -= dd; } bool ok(ll x) { return x>=d+m; } int main() { //#ifndef atom //freopen(".in", "r", stdin); //freopen(".out", "w", stdout); //#endif scanf("%lld %lld %d", &m, &d, &n); for(int i = 0; i< n; i++) scanf("%lld", &x[i]); sort(x, x+n); //if(2*d< m) //{ int pos = LU(m-d); if(pos == n) fail(); int cnt = 0; for(int i = n-1; i>= 0; i--) { if(i == pos) continue; if(d>x[i]) fail(); if(ok(x[max(pos, i)])) { printf("%d\n", cnt+1); return 0; } use(x[i]); cnt++; //cout << m << " " << d << endl; } //} if(ok(x[pos])) printf("%d\n", cnt+1); else printf("0\n"); }

Compilation message (stderr)

tak.cpp: In function 'int main()':
tak.cpp:42:38: 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:43:51: 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", &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...