답안 #860223

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
860223 2023-10-12T08:57:44 Z naneosmic Sure Bet (CEOI17_sure) C++14
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
#define int long long
#define float long double
#define endl "\n"
using namespace std;
bool f(float a, float b){
    return a>b;
}
float binarySearch(vector<float>arr, float l, float r, float x){
    if(arr[l]>=x)
        return l;
    if(arr[r]<=x)
        return r-1;
    while (l <= r) {
        float m = l + (r - l) / 2;
        if(arr[m]<=x && arr[m+1]>=x)
            return m;
        if (arr[m+1] < x)
            l = m + 1;
        else
            r = m - 1;
    }
    return -1;
}
signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    float n;
    cin>>n;
    vector<float>a(n);
    vector<float>b(n);
    for(float i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    sort(a.begin(),a.end(),f);
    sort(b.begin(),b.end(),f);
    vector<float>b_pref;
    float s=0;
    for(float i=0;i<n;i++){
        s+=b[i];
        b_pref.push_back(s);
    }
    s=0;
    float score=0;
    for(float i=0;i<n;i++){
        s+=a[i];
        float j=binarySearch(b_pref,0,n-1,s);
        float s1=min(s,b_pref[j])-i-j-2;
        float s2=min(s,b_pref[j+1])-i-j-3;
        score=max(score,s2);
        score=max(score,s1);
    }
    printf("%.4lf",(float)score);
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:54:17: warning: format '%lf' expects argument of type 'double', but argument 2 has type 'long double' [-Wformat=]
   54 |     printf("%.4lf",(float)score);
      |             ~~~~^  ~~~~~~~~~~~~
      |                 |  |
      |                 |  long double
      |                 double
      |             %.4Lf
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -