답안 #152619

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
152619 2019-09-08T15:14:02 Z Mercenary Sure Bet (CEOI17_sure) C++14
100 / 100
122 ms 5240 KB
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>

#define pb push_back
#define mp make_pair
#define taskname "A"

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef tree <int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

const int maxn = 1e5 + 5;
int n;
ld a[maxn] , b[maxn];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    if(fopen(taskname".INP","r")){
		freopen(taskname".INP", "r",stdin);
		freopen(taskname".OUT", "w",stdout);
    }
    cin >> n;
    for(int i = 1 ; i <= n ; ++i){
        cin >> a[i] >> b[i];
    }
    sort(a + 1 , a + n + 1);
    sort(b + 1 , b + n + 1);
    int j = n;
    ld suml = 0 , sumr = 0;
    ld res = 0;
    for(int i = n ; i >= 0 ; --i){
        res = max(res , min(suml, sumr) - 2 * n + i + j);
//        cout << suml << " " << sumr << endl;
        while(j >= 1 && suml > sumr){
            sumr += b[j--];
            res = max(res , min(suml, sumr) - 2 * n + i + j);
        }
//        cout << suml << " " << sumr << endl;
        suml += a[i];
        res = max(res , min(suml, sumr) - 2 * n + i + j - 1);
    }
    cout << fixed << setprecision(4) << res;
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:26:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen(taskname".INP", "r",stdin);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
sure.cpp:27:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   freopen(taskname".OUT", "w",stdout);
   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 376 KB Output is correct
9 Correct 3 ms 376 KB Output is correct
10 Correct 2 ms 376 KB Output is correct
11 Correct 2 ms 376 KB Output is correct
12 Correct 4 ms 376 KB Output is correct
13 Correct 4 ms 376 KB Output is correct
14 Correct 3 ms 376 KB Output is correct
15 Correct 3 ms 376 KB Output is correct
16 Correct 3 ms 376 KB Output is correct
17 Correct 112 ms 4984 KB Output is correct
18 Correct 113 ms 4848 KB Output is correct
19 Correct 114 ms 4984 KB Output is correct
20 Correct 113 ms 4856 KB Output is correct
21 Correct 122 ms 5240 KB Output is correct
22 Correct 114 ms 4984 KB Output is correct
23 Correct 117 ms 4968 KB Output is correct
24 Correct 116 ms 4976 KB Output is correct
25 Correct 113 ms 4856 KB Output is correct
26 Correct 122 ms 5212 KB Output is correct