# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
879279 |
2023-11-27T05:23:38 Z |
vjudge1 |
Sure Bet (CEOI17_sure) |
C++17 |
|
72 ms |
26964 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma optimization_level 3
// Defines
#define pb push_back // kak push_back 5
#define endl '\n'
#define FOR(i,start,end) for(int i = start;i < end;i ++)
#define REV(i,start,end) for(int i = start;i >= end;i --)
#define precal(x) fixed << setprecision(x)
#define F first
#define S second
#define sz(x) (ll)x.size()
#define all(x) (x).begin(),(x).end()
#define m_p make_pair
#define mt make_tuple
#define str to_string
// #ifndef ONLINE_JUDGE
// #define cerr if(false) cerr
// #endif
const ll mxn = 1e6 + 1;
// const ll k = 400;
// const ll org = 10000;
const ll inf = 1e9 + 7;
// const ll mod = 998244353;
ll n,m,t[4 * mxn],a[mxn];
bool au,us[mxn];
ll used[mxn];
vector <ll> v[mxn];
ll deg(ll x,ll p){
ll ans = 1;
while(p --) ans *= x;
return ans;
}
int main(){
// freopen("sparse.in","r",stdin);
// freopen("sparse.out","w",stdout);
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
ll tt = 1;
// cin >> tt;
while(tt --){
ll n;
cin >> n;
vector <double> a(n),b(n);
FOR(i,0,n){
cin >> a[i] >> b[i];
}
sort(a.rbegin(),a.rend()),sort(b.rbegin(),b.rend());
double mx = 0.0,sum = 0.0,summ = 0.0,x = 0,y = 0;
while(x < n || y < n){
if(x == 0 && y == 0){
sum = a[x],summ = b[y];
mx = max(mx,min(sum,summ) - (x + y + 2));
}
if(sum > summ){
if(y + 1 < n){
y ++;
summ += b[y];
mx = max(mx,min(sum,summ) - (x + y + 2));
}
else break;
}
else if(sum < summ){
if(x + 1 < n){
x ++;
sum += a[x];
mx = max(mx,min(sum,summ) - (x + y + 2));
}
else break;
}
else{
if(x + 1 < n){
x ++;
sum += a[x];
}
else{
y ++;
summ += b[y];
}
mx = max(mx,min(sum,summ) - (x + y + 2));
}
}
cout << precal(4) << mx;
}
}
Compilation message
sure.cpp:9: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
9 | #pragma GCC optimization ("O3")
|
sure.cpp:10: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
10 | #pragma GCC optimization ("unroll-loops")
|
sure.cpp:11: warning: ignoring '#pragma optimization_level ' [-Wunknown-pragmas]
11 | #pragma optimization_level 3
|
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
25180 KB |
Output is correct |
2 |
Correct |
6 ms |
25180 KB |
Output is correct |
3 |
Correct |
6 ms |
25180 KB |
Output is correct |
4 |
Correct |
6 ms |
25264 KB |
Output is correct |
5 |
Correct |
6 ms |
25180 KB |
Output is correct |
6 |
Correct |
5 ms |
25212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
25180 KB |
Output is correct |
2 |
Correct |
6 ms |
25180 KB |
Output is correct |
3 |
Correct |
6 ms |
25180 KB |
Output is correct |
4 |
Correct |
6 ms |
25264 KB |
Output is correct |
5 |
Correct |
6 ms |
25180 KB |
Output is correct |
6 |
Correct |
5 ms |
25212 KB |
Output is correct |
7 |
Correct |
7 ms |
25180 KB |
Output is correct |
8 |
Correct |
5 ms |
25180 KB |
Output is correct |
9 |
Correct |
6 ms |
25180 KB |
Output is correct |
10 |
Correct |
5 ms |
25180 KB |
Output is correct |
11 |
Correct |
5 ms |
25208 KB |
Output is correct |
12 |
Correct |
7 ms |
25176 KB |
Output is correct |
13 |
Correct |
6 ms |
25180 KB |
Output is correct |
14 |
Correct |
6 ms |
25180 KB |
Output is correct |
15 |
Correct |
6 ms |
25176 KB |
Output is correct |
16 |
Correct |
6 ms |
25180 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
25180 KB |
Output is correct |
2 |
Correct |
6 ms |
25180 KB |
Output is correct |
3 |
Correct |
6 ms |
25180 KB |
Output is correct |
4 |
Correct |
6 ms |
25264 KB |
Output is correct |
5 |
Correct |
6 ms |
25180 KB |
Output is correct |
6 |
Correct |
5 ms |
25212 KB |
Output is correct |
7 |
Correct |
7 ms |
25180 KB |
Output is correct |
8 |
Correct |
5 ms |
25180 KB |
Output is correct |
9 |
Correct |
6 ms |
25180 KB |
Output is correct |
10 |
Correct |
5 ms |
25180 KB |
Output is correct |
11 |
Correct |
5 ms |
25208 KB |
Output is correct |
12 |
Correct |
7 ms |
25176 KB |
Output is correct |
13 |
Correct |
6 ms |
25180 KB |
Output is correct |
14 |
Correct |
6 ms |
25180 KB |
Output is correct |
15 |
Correct |
6 ms |
25176 KB |
Output is correct |
16 |
Correct |
6 ms |
25180 KB |
Output is correct |
17 |
Correct |
65 ms |
26716 KB |
Output is correct |
18 |
Correct |
65 ms |
26828 KB |
Output is correct |
19 |
Correct |
64 ms |
26824 KB |
Output is correct |
20 |
Correct |
63 ms |
26716 KB |
Output is correct |
21 |
Correct |
66 ms |
26716 KB |
Output is correct |
22 |
Correct |
65 ms |
26712 KB |
Output is correct |
23 |
Correct |
63 ms |
26716 KB |
Output is correct |
24 |
Correct |
64 ms |
26716 KB |
Output is correct |
25 |
Correct |
63 ms |
26712 KB |
Output is correct |
26 |
Correct |
72 ms |
26964 KB |
Output is correct |