Submission #708214

#TimeUsernameProblemLanguageResultExecution timeMemory
708214segir187Seesaw (JOI22_seesaw)C++17
1 / 100
1 ms328 KiB
#include <bits/stdc++.h> //Grzegorz Krawczyk using namespace std; typedef unsigned long long LL; typedef long double LD; #define rep(a,b) for(int a=0;a<(b);a++) #define rep2(a,b) for(int a=1;a<=(b);a++) #define st first #define nd second #define pb push_back #define mp make_pair const int INF=INT_MAX/2; const LL LINF=LLONG_MAX/2; const int LIM=2e5+7; ///flagi kompilacji: ///g++ -std=c++17 -static -Wall -pedantic -O3 -s -lm -o see see.cpp __int128 t[LIM]; __int128 SUM; int n; __int128 solve(__int128 P) { __int128 sum=SUM; int m=n; __int128 K=sum/m; int pi=1,ki=n; while(pi!=ki) { __int128 csr=sum/m; m--; if((sum-t[ki])/m>=P) { sum-=t[ki--]; K=max(K,sum/m); } else { sum-=t[pi++]; K=max(K,sum/m); } } return K-P+1; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin>>n; rep2(i,n) { LL a; cin>>a; t[i]=a*LL(1e10); SUM+=t[i]; } __int128 p=0,k=SUM/n+1; __int128 pw=solve(p); __int128 kw=LINF; kw*=kw; while(k-p>1) { __int128 sr=(p+k)/2; __int128 srw=solve(sr); if(srw<=pw) { pw=srw; p=sr; } else { kw=srw; k=sr; } } if(kw<pw) { swap(p,k); swap(pw,kw); } p=pw; __int128 BIL=1e10; __int128 pom=p/BIL; LL a=pom; cout<<a<<'.'; pom=p%BIL; a=pom; int cnt=0; LL x=1; rep(i,10) { if(a/x==0) break; else cnt++; } a=pom; cnt=10-cnt; rep(i,cnt) cout<<'0'; cout<<a<<'\n'; return 0; }

Compilation message (stderr)

seesaw.cpp: In function '__int128 solve(__int128)':
seesaw.cpp:28:18: warning: unused variable 'csr' [-Wunused-variable]
   28 |         __int128 csr=sum/m;
      |                  ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...