Submission #865513

#TimeUsernameProblemLanguageResultExecution timeMemory
865513vjudge1Sure Bet (CEOI17_sure)C++17
Compilation error
0 ms0 KiB
/// tree bends in youth /// 24 .10.2023 /// success is doing same thing in every single day!!! #include <bits/stdc++.h> #define ll long long #define pb push_back #define all(x) x.begin(), x.end() #define F first #define S second using namespace std; const ll N =2e5+ 5; const ll NN =2e6 + 5; const ll INF = -1e1; const ll MOD = 1e9 + 7; const ll LG = 18; const ll k = 316; int n; long double a[N],b[N],pl[N],pr[N]; void solve(){ cin >> n; for(int i = 1;i <= n;i++){ cin >> a[i] >> b[i]; } sort(a + 1,a + n + 1); sort(b + 1,b + n + 1); reverse(a + 1,a+ n + 1); reverse(b + 1,b + n + 1); for(int i = 1;i <= n;i++){ pr[i] = pr[i - 1] + b[i]; pl[i] = pl[i - 1] + a[i]; } long double ans = 0; for(int i = 1;i <= n;i++){ if(pl[i] < i)break; int l = 1,r = n; while(l < r){ int mid = (l + r) / 2; if(pl[i] < long double(i + mid))r = mid - 1; long double sum = i + mid; long double res = min(pl[i] - sum,pr[mid] -sum ); if(res < ans)r = mid; else l = mid + 1; ans= max(ans,res); } } cout <<fixed << setprecision(9) <<ans; } main (){ ios_base::sync_with_stdio(0); cin.tie(0); // freopen("input.txt","r",stdin); // freopen("output.txt","w",stdout); ll abd= 1; // cin >> abd; for(ll i = 1;i <= abd;i++){ // cout << "Case " << i << ":\n"; solve(); } }

Compilation message (stderr)

sure.cpp: In function 'void solve()':
sure.cpp:38:24: error: expected primary-expression before 'long'
   38 |             if(pl[i] < long double(i + mid))r = mid - 1;
      |                        ^~~~
sure.cpp:38:23: error: expected ')' before 'long'
   38 |             if(pl[i] < long double(i + mid))r = mid - 1;
      |               ~       ^~~~~
      |                       )
sure.cpp: At global scope:
sure.cpp:48:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   48 | main (){
      | ^~~~