Submission #453446

# Submission time Handle Problem Language Result Execution time Memory
453446 2021-08-04T11:30:38 Z marcipan5000 Sure Bet (CEOI17_sure) C++14
100 / 100
146 ms 5448 KB
#include <bits/stdc++.h>

using namespace std;

typedef long double 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(x);
        cin >> x;
        b.push_back(x);
    }

    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;
    int l=0;
    for (int i=0;i<a.size();i++) {
        while ((l<b.size())&&(b[l]<a[i])) {
            ans=max(ans,min(a[i],b[l])-(long double)(i+l));
            l++;
        }
        if (l<b.size()) {
            ans=max(ans,min(a[i],b[l])-(long double)(i+l));
        }
    }
    printf("%.4lf",(double)ans);

/*
    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 double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for (int i=1;i<a.size();i++) {
      |                  ~^~~~~~~~~
sure.cpp:36:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for (int i=0;i<a.size();i++) {
      |                  ~^~~~~~~~~
sure.cpp:37:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long double>::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: 'int' and 'std::vector<long double>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         if (l<b.size()) {
      |             ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 1 ms 308 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 332 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 2 ms 332 KB Output is correct
14 Correct 2 ms 332 KB Output is correct
15 Correct 2 ms 332 KB Output is correct
16 Correct 2 ms 332 KB Output is correct
17 Correct 129 ms 4916 KB Output is correct
18 Correct 132 ms 5032 KB Output is correct
19 Correct 140 ms 4972 KB Output is correct
20 Correct 137 ms 5036 KB Output is correct
21 Correct 142 ms 5420 KB Output is correct
22 Correct 131 ms 5148 KB Output is correct
23 Correct 134 ms 4964 KB Output is correct
24 Correct 134 ms 5032 KB Output is correct
25 Correct 140 ms 5084 KB Output is correct
26 Correct 146 ms 5448 KB Output is correct