# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
843482 | vjudge1 | Sure Bet (CEOI17_sure) | C++17 | 2039 ms | 6480 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
///***LTT***///
/// ->TUYEN QUOC GIA<- ///
#include<bits/stdc++.h>
//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("popcnt")
//#define int long long
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define CHECKBIT(mask,i) ((mask>>(i) )&1) // == 1 la bat, == 0 la tat
#define OFFBIT(mask,i) ((1<<(i))^mask) // tat bit thu i
#define ONBIT(mask,i) ((1<<(i))mask) // bat bit thu i
using namespace std;
const long long oo = 1e9+7;
const int N = 2 * 1e5 + 10;
int n;
long double a[N], b[N], L, R, cntl, cntr, ans;
bool cmp (long double a,long double b){
return a > b;
}
void inp(){
cin >> n;
for (int i = 1;i <= n;i++){
cin >> a[i] >> b[i];
}
return;
}
void solve(){
sort(a+1,a+n+1,cmp);
sort(b+1,b+n+1,cmp);
// for (int i = 1;i <= n;i++){
// cout << a[i] <<" "<< b[i] <<"\n";
// }
for (int i = 1;i <= n;i++){
cntl++;
cntr = 0;
L += a[i];
R = 0;
for (int j = 1;j <= n;j++){
cntr++;
R += b[j];
ans = max(ans, min(R - (cntl + cntr), L - (cntl + cntr) ));
}
}
cout << fixed << setprecision(4) << ans;
return;
}
int main(){
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
cout.tie(NULL);
if (fopen("file.inp", "r")){
freopen("file.inp", "r", stdin);
freopen("file.out", "w", stdout);
}
//int t;
//cin >> t;
//while(t--){
inp();
solve();
//}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |