답안 #800051

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
800051 2023-08-01T09:36:46 Z amogususus Sure Bet (CEOI17_sure) C++17
100 / 100
82 ms 8280 KB
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define prec fixed<<setprecision
#define all(x) x.begin(),x.end()
#define pll pair<ll,ll>
#define endl '\n'
#define open(name) if(fopen(name".inp", "r")){freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout);}
#define fout(name) freopen(name".out", "w", stdout);
using namespace std;
const int maxN=2e5+69;
const int mod=1e9+7;
ll n;
ld a[maxN],b[maxN],pa[maxN],pb[maxN],r=0;
void Enter(){
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i]>>b[i];
    sort(a+1,a+n+1,greater<ld>());
    sort(b+1,b+n+1,greater<ld>());
    for(int i=1;i<=n;i++)pa[i]=pa[i-1]+a[i],pb[i]=pb[i-1]+b[i];
    for(int i=1;i<=n;i++){
        r=max(r,min(pa[i]-2*i  ,pb[i]  -2*i  ));
        r=max(r,min(pb[i]-2*i+1,pa[i-1]-2*i+1));
        r=max(r,min(pa[i]-2*i+1,pb[i-1]-2*i+1));
    }
    ll j=0;
    for(int i=0;i<=n;i++){
        while(j<n&&pb[j+1]<=pa[i])j++;
        if(j)r=max(r,min(pa[i]-i-j+1,pb[j-1]-i-j+1));
        r=max(r,min(pa[i]-i-j,pb[j]-i-j));
        if(j<n)r=max(r,min(pa[i]-i-j-1,pb[j+1]-i-j-1));
    }
    j=0;
    for(int i=0;i<=n;i++){
        while(j<n&&pa[j+1]<=pb[i])j++;
        if(j)r=max(r,min(pb[i]-i-j+1,pa[j-1]-i-j+1));
        r=max(r,min(pb[i]-i-j,pa[j]-i-j));
        if(j<n)r=max(r,min(pb[i]-i-j-1,pa[j+1]-i-j-1));
    }
    cout<<prec(4)<<r;
}
//amogus
signed main(){
    open("SUREBET");
    cin.tie(nullptr);ios_base::sync_with_stdio(NULL);
    //int t=1;cin>>t;while(t--)
    Enter();
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:9:54: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 | #define open(name) if(fopen(name".inp", "r")){freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout);}
      |                                               ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sure.cpp:45:5: note: in expansion of macro 'open'
   45 |     open("SUREBET");
      |     ^~~~
sure.cpp:9:87: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 | #define open(name) if(fopen(name".inp", "r")){freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout);}
      |                                                                                ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
sure.cpp:45:5: note: in expansion of macro 'open'
   45 |     open("SUREBET");
      |     ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 0 ms 340 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 2 ms 340 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 73 ms 7860 KB Output is correct
18 Correct 73 ms 7856 KB Output is correct
19 Correct 72 ms 7976 KB Output is correct
20 Correct 75 ms 7912 KB Output is correct
21 Correct 82 ms 8280 KB Output is correct
22 Correct 74 ms 7932 KB Output is correct
23 Correct 80 ms 7908 KB Output is correct
24 Correct 79 ms 7952 KB Output is correct
25 Correct 73 ms 7928 KB Output is correct
26 Correct 76 ms 8268 KB Output is correct