답안 #405668

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
405668 2021-05-16T16:42:43 Z Hazem Sure Bet (CEOI17_sure) C++14
100 / 100
180 ms 4548 KB
#include <bits/stdc++.h>
using namespace std;
 
#define LL long long
#define F first
#define S second
#define pii pair<int,int>
#define piii pair<pair<int,int>,int>

const int N = 3e5+10;
const int M = 3e2+10;
const LL INF = 1e9;
const LL LINF = 2e18;
const LL MOD = 1e9+7;   
const double PI = 3.141592653589793;

vector<double>vec[2];
int n;
double pr[N];

double calc(double sum,double cnt){

    int l = 0,r = n-1;
    while(l<r){
        int mid = (l+r+1)/2;
        double ans1 = pr[mid]-cnt;
        if(ans1<=sum-mid-1)l = mid;
        else r = mid-1;
    }
    double ret = 0;
    for(int i=max(0,l-10);i<min(n,l+10);i++)
        ret = max(ret,min(pr[i]-cnt,sum-i-1));
    
    return ret;
}

int main(){

    //freopen("out.txt","w",stdout);

    scanf("%d",&n);

    for(int i=1;i<=n;i++)
        for(int j=0;j<2;j++){
            double x;cin>>x;
            vec[j].push_back(x);
        }

    for(int j=0;j<2;j++){
        sort(vec[j].begin(),vec[j].end());
        reverse(vec[j].begin(),vec[j].end());
    }

    for(int i=0;i<n;i++)
        pr[i] = (i?pr[i-1]:0)+vec[0][i]-1.0;

    double ans = 0,sum = 0;
    for(int i=0;i<n;i++){
        sum += vec[1][i]-1;
        ans = max(ans,calc(sum,i+1));
    }

    printf("%.4lf\n",ans);
}   

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:41:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 292 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 292 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 204 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 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 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 4 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 292 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 1 ms 204 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 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 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 4 ms 332 KB Output is correct
17 Correct 157 ms 4128 KB Output is correct
18 Correct 155 ms 4172 KB Output is correct
19 Correct 158 ms 4156 KB Output is correct
20 Correct 156 ms 4216 KB Output is correct
21 Correct 180 ms 4500 KB Output is correct
22 Correct 155 ms 4216 KB Output is correct
23 Correct 157 ms 4144 KB Output is correct
24 Correct 158 ms 4296 KB Output is correct
25 Correct 154 ms 4212 KB Output is correct
26 Correct 177 ms 4548 KB Output is correct