Submission #122619

# Submission time Handle Problem Language Result Execution time Memory
122619 2019-06-28T19:20:52 Z davitmarg Sure Bet (CEOI17_sure) C++17
0 / 100
2 ms 376 KB
/*DavitMarg*/
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <unordered_map>
#include <bitset>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <ctype.h>
#include <stdlib.h>
#include <cassert>
#include <fstream>
#define mod 998244353ll
#define LL long long
#define LD long double
#define MP make_pair
#define PB push_back
#define all(v) v.begin(),v.end()
using namespace std;

int n,k;
LD a[100005],b[100005],sx,sy,ans=-mod;

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
		cin>>a[i]>>b[i];
    sort(a+1,a+1+n);
    sort(b+1,b+1+n);
    reverse(a+1,a+1+n);
    reverse(b+1,b+1+n);
    for(int i=1;i<=n;i++)
	{
        sx+=a[i];
        k=0;
        sy=0;
        while(k<n && min(sx,sy+b[k+1])-i-k-1>=min(sx,sy)-i-k)
		{
            k++;
            sy+=b[k];
		}
		ans=max(ans,min(sx,sy)-i-k);
	}
    printf("%.4lf\n",ans);
	return 0;
}


/*





*/


Compilation message

sure.cpp: In function 'int main()':
sure.cpp:52:25: warning: format '%lf' expects argument of type 'double', but argument 2 has type 'long double' [-Wformat=]
     printf("%.4lf\n",ans);
                         ^
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -