답안 #877991

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
877991 2023-11-24T01:45:13 Z fanwen Sure Bet (CEOI17_sure) C++17
100 / 100
84 ms 3828 KB
#pragma GCC optimize("O2")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
#define mp make_pair
#define ii pair<int,int>
#define MASK(i) (1LL<<(i))
#define BIT(x,i) (((x)>>(i))&1)
#define all(x) (x).begin(),(x).end()

using namespace std;
const int maxn = 1e5 + 5;
const int    N = 1e3 + 1;
const int  mod = 1e9 + 7;

template <class X,class Y>bool maximize(X &a,Y b) {
        if(a<b)return a=b,true;
        return false;}

template <class X,class Y>bool minimize(X &a,Y b) {
        if(a>b)return a=b,true;
        return false;}

#define TASK ""
void file() {
        freopen(TASK ".inp", "r", stdin);
        freopen(TASK ".out", "w", stdout);}
#define fasterIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ld long double
int n,i,j;
ld a[maxn],b[maxn];
int na,nb;
ld A,B;
ld Max = 0.000;
int main() {
        // file();
        fasterIO;
        cin >>n;
        for(i=1;i<=n;i++) cin>>a[i]>>b[i],a[i]--,b[i]--;
        sort(a+1,a+n+1,greater<ld>());
        sort(b+1,b+n+1,greater<ld>());
        for(i=1;i<=n;i++){
                A += a[i] , ++na;
                while(nb < n && min(A-nb,B-na) < min(A - nb -1, B + b[nb+1] - na)){
                        B += b[nb+1];
                        nb++;
                }
                maximize(Max,min(A-nb,B-na));
        }
        cout << fixed << setprecision(4) << Max << '\n';
        return 0;
}

Compilation message

sure.cpp: In function 'void file()':
sure.cpp:28:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   28 |         freopen(TASK ".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
sure.cpp:29:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |         freopen(TASK ".out", "w", stdout);}
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2392 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2392 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 0 ms 2392 KB Output is correct
3 Correct 0 ms 2396 KB Output is correct
4 Correct 0 ms 2396 KB Output is correct
5 Correct 0 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 0 ms 2396 KB Output is correct
12 Correct 1 ms 2396 KB Output is correct
13 Correct 1 ms 2396 KB Output is correct
14 Correct 1 ms 2396 KB Output is correct
15 Correct 1 ms 2396 KB Output is correct
16 Correct 1 ms 2396 KB Output is correct
17 Correct 67 ms 3664 KB Output is correct
18 Correct 69 ms 3420 KB Output is correct
19 Correct 66 ms 3420 KB Output is correct
20 Correct 84 ms 3364 KB Output is correct
21 Correct 73 ms 3828 KB Output is correct
22 Correct 69 ms 3668 KB Output is correct
23 Correct 66 ms 3420 KB Output is correct
24 Correct 67 ms 3412 KB Output is correct
25 Correct 66 ms 3380 KB Output is correct
26 Correct 72 ms 3412 KB Output is correct