Submission #27845

#TimeUsernameProblemLanguageResultExecution timeMemory
27845khsoo01Sparklers (JOI17_sparklers)C++11
0 / 100
0 ms2800 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; const long double eps = 1e-9; const ll N = 100005, inf = 1e9; ll n, k, t, a[N]; bool can (ll P) { ll S = k, E = k, C = 0; for(ll i=1;i<n;i++) { if(a[S]-a[S-1] < a[E+1]-a[E]) { C += a[S]-a[S-1]; S--; } else {C += a[E+1]-a[E]; E++;} if(i*P*2+eps < (long double)C/t) return false; } return true; } int main() { scanf("%lld%lld%lld",&n,&k,&t); bool f = false; for(ll i=1;i<=n;i++) { scanf("%lld",&a[i]); if(a[i] != a[i-1]) f = true; } if(!f) {puts("0"); return 0;} a[0] = -2*inf; a[n+1] = 2*inf; ll S = 1, E = inf; while(S<E) { ll M = (S+E)/2; can(M) ? E = M : S = M+1; } printf("%lld\n",S); }

Compilation message (stderr)

sparklers.cpp: In function 'int main()':
sparklers.cpp:22:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld%lld%lld",&n,&k,&t);
                                ^
sparklers.cpp:25:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld",&a[i]);
                      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...