Submission #453420

# Submission time Handle Problem Language Result Execution time Memory
453420 2021-08-04T11:22:45 Z marcipan5000 Sure Bet (CEOI17_sure) C++14
0 / 100
3 ms 204 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

int n;
long double x;
vector<ll> a,b;

bool kis(ll a,ll b) {
    return(a>b);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n;
    a.push_back(0);
    b.push_back(0);
    for (int i=0;i<n;i++) {
        cin >> x;
        a.push_back((long long int)(x*10000));
        cin >> x;
        b.push_back((long long int)(x*10000));
    }

    sort(++a.begin(),a.end(),kis);
    sort(++b.begin(),b.end(),kis);
    for (int i=1;i<a.size();i++) {
        a[i]+=a[i-1];
        b[i]+=b[i-1];
    }
    ll ans=0;
    ll l=0;
    for (ll i=0;i<a.size();i++) {
        while ((l<b.size())&&(b[l]<a[i])) {
            ans=max(ans,min(a[i],b[l])-(i+l)*10000);
            l++;
        }
        if (l<b.size()) {
            ans=max(ans,min(a[i],b[l])-(i+l)*10000);
        }
    }
    long double p=ans;
    p=p/10000;
    printf("%.4lf",(double)p);

    /*
    for (int i=0;i<a.size();i++) {
        cout << a[i] << " ";
    }
    cout << endl;
    for (int i=0;i<a.size();i++) {
        cout << b[i] << " ";
    }
    cout << endl;
    */
    return 0;
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:30:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for (int i=1;i<a.size();i++) {
      |                  ~^~~~~~~~~
sure.cpp:36:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for (ll i=0;i<a.size();i++) {
      |                 ~^~~~~~~~~
sure.cpp:37:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         while ((l<b.size())&&(b[l]<a[i])) {
      |                 ~^~~~~~~~~
sure.cpp:41:14: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         if (l<b.size()) {
      |             ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 204 KB Output is correct
2 Incorrect 3 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 204 KB Output is correct
2 Incorrect 3 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 204 KB Output is correct
2 Incorrect 3 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -