답안 #453414

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
453414 2021-08-04T11:19:56 Z marcipan5000 Sure Bet (CEOI17_sure) C++14
0 / 100
1 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(int(x*10000));
        cin >> x;
        b.push_back(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;
    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])-(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:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::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 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: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         if (l<b.size()) {
      |             ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -