답안 #453409

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
453409 2021-08-04T11:17:09 Z marcipan5000 Sure Bet (CEOI17_sure) C++14
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>

using namespace std;

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

bool kis(int a,int 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];
    }
    int 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;
    cout << setprecision(6) << p/10000 << endl;

    /*
    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:28:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for (int i=1;i<a.size();i++) {
      |                  ~^~~~~~~~~
sure.cpp:34:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for (int i=0;i<a.size();i++) {
      |                  ~^~~~~~~~~
sure.cpp:35:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         while ((l<b.size())&&(b[l]<a[i])) {
      |                 ~^~~~~~~~~
sure.cpp:39:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |         if (l<b.size()) {
      |             ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -