# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
110958 |
2019-05-13T11:29:17 Z |
dndhk |
Sure Bet (CEOI17_sure) |
C++14 |
|
79 ms |
3816 KB |
#include <bits/stdc++.h>
#define pb push_back
#define all(v) ((v).begin(), (v).end())
#define sortv(v) sort(all(v))
#define sz(v) ((int)(v).size())
#define uniqv(v) (v).erase(unique(all(v)), (v).end())
#define umax(a, b) (a)=max((a), (b))
#define umin(a, b) (a)=min((a), (b))
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define rep(i,n) FOR(i,1,n)
#define rep0(i,n) FOR(i,0,(int)(n)-1)
#define FI first
#define SE second
#define INF 2000000000
#define INFLL 1000000000000000000LL
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int N;
vector<double> v1, v2;
double ans = 0;
double used=0;
double s1=0, s2=0;
int main(){
cin>>N;
for(int i=0; i<N; i++){
double x, y;
scanf("%lf %lf", &x, &y);
v1.pb(x); v2.pb(y);
}
sort(v1.begin(), v1.end()); sort(v2.begin(), v2.end());
while(!v1.empty() || !v2.empty()){
used += 1.0;
if(v1.empty()){
s2+=v2.back(); v2.pop_back();
}else if(v2.empty()){
s1+=v1.back(); v1.pop_back();
}else{
if(s1<s2){
s1+=v1.back(); v1.pop_back();
}else{
s2+=v2.back(); v2.pop_back();
}
}
ans = max(ans, min(s1-used, s2-used));
}
printf("%.4lf", ans);
return 0;
}
Compilation message
sure.cpp: In function 'int main()':
sure.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%lf %lf", &x, &y);
~~~~~^~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
3 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
3 ms |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
4 ms |
384 KB |
Output is correct |
14 |
Correct |
4 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
4 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
256 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
256 KB |
Output is correct |
7 |
Correct |
3 ms |
256 KB |
Output is correct |
8 |
Correct |
2 ms |
256 KB |
Output is correct |
9 |
Correct |
2 ms |
256 KB |
Output is correct |
10 |
Correct |
3 ms |
256 KB |
Output is correct |
11 |
Correct |
2 ms |
384 KB |
Output is correct |
12 |
Correct |
4 ms |
384 KB |
Output is correct |
13 |
Correct |
4 ms |
384 KB |
Output is correct |
14 |
Correct |
4 ms |
384 KB |
Output is correct |
15 |
Correct |
3 ms |
384 KB |
Output is correct |
16 |
Correct |
4 ms |
384 KB |
Output is correct |
17 |
Correct |
76 ms |
3428 KB |
Output is correct |
18 |
Correct |
73 ms |
3460 KB |
Output is correct |
19 |
Correct |
66 ms |
3724 KB |
Output is correct |
20 |
Correct |
67 ms |
3528 KB |
Output is correct |
21 |
Correct |
69 ms |
3816 KB |
Output is correct |
22 |
Correct |
79 ms |
3500 KB |
Output is correct |
23 |
Correct |
70 ms |
3424 KB |
Output is correct |
24 |
Correct |
68 ms |
3424 KB |
Output is correct |
25 |
Correct |
73 ms |
3556 KB |
Output is correct |
26 |
Correct |
73 ms |
3812 KB |
Output is correct |