답안 #62708

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
62708 2018-07-29T21:23:48 Z eriksuenderhauf Sure Bet (CEOI17_sure) C++11
100 / 100
105 ms 16764 KB
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <string>
#include <fstream>
#define ni(n) scanf("%d", &n)
#define nl(n) scanf("%lf", &n)
#define nai(a,n) for (int i = 0; i < (n); i++) ni((a)[i])
#define nal(a,n) for (int i = 0; i < (n); i++) nl((a)[i])
#define case(t) printf("Case #%d: ", (t))
#define pii pair<int, int>
#define vii vector<pii>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define f first
#define s second
typedef long long ll;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e5 + 5;
const double eps = 1e-9;
using namespace std;
ll a[MAXN], b[MAXN];

int main()
{
    int n;
    ni(n);
    for (int i = 1; i <= n; i++)
    {
        double x, y;
        nl(x), nl(y);
        x *= 10000;
        y *= 10000;
        a[i] = round(x);
        b[i] = round(y);
    }
    sort(a + 1, a + n + 1);
    sort(b + 1, b + n + 1);
    reverse(a + 1, a + n + 1);
    reverse(b + 1, b + n + 1);
    ll ans = 0;
    int r = 0;
    ll sa = 0, sb = 0;
    for (int l = 0; l <= n; l++)
    {
        sa += a[l];
        while (r < n && min(sa, sb + b[r + 1]) - 10000ll * (l + r + 1) > min(sa, sb) - 10000ll * (l + r))
        {
            r++;
            sb += b[r];
        }
        ans = max(min(sa, sb) - 10000ll * (l + r), ans);
    }
    double tmp = ans / 10000.;
    printf("%.4lf", tmp);
    return 0;
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:9:20: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
 #define ni(n) scanf("%d", &n)
               ~~~~~^~~~~~~~~~
sure.cpp:33:5: note: in expansion of macro 'ni'
     ni(n);
     ^~
sure.cpp:37:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         nl(x), nl(y);
              ^
sure.cpp:37:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 2 ms 548 KB Output is correct
5 Correct 3 ms 548 KB Output is correct
6 Correct 3 ms 548 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 2 ms 548 KB Output is correct
5 Correct 3 ms 548 KB Output is correct
6 Correct 3 ms 548 KB Output is correct
7 Correct 3 ms 548 KB Output is correct
8 Correct 2 ms 664 KB Output is correct
9 Correct 3 ms 664 KB Output is correct
10 Correct 2 ms 688 KB Output is correct
11 Correct 2 ms 696 KB Output is correct
12 Correct 3 ms 824 KB Output is correct
13 Correct 3 ms 824 KB Output is correct
14 Correct 3 ms 824 KB Output is correct
15 Correct 3 ms 824 KB Output is correct
16 Correct 4 ms 824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB Output is correct
2 Correct 2 ms 356 KB Output is correct
3 Correct 2 ms 484 KB Output is correct
4 Correct 2 ms 548 KB Output is correct
5 Correct 3 ms 548 KB Output is correct
6 Correct 3 ms 548 KB Output is correct
7 Correct 3 ms 548 KB Output is correct
8 Correct 2 ms 664 KB Output is correct
9 Correct 3 ms 664 KB Output is correct
10 Correct 2 ms 688 KB Output is correct
11 Correct 2 ms 696 KB Output is correct
12 Correct 3 ms 824 KB Output is correct
13 Correct 3 ms 824 KB Output is correct
14 Correct 3 ms 824 KB Output is correct
15 Correct 3 ms 824 KB Output is correct
16 Correct 4 ms 824 KB Output is correct
17 Correct 78 ms 3656 KB Output is correct
18 Correct 79 ms 5140 KB Output is correct
19 Correct 102 ms 6552 KB Output is correct
20 Correct 105 ms 7820 KB Output is correct
21 Correct 90 ms 9532 KB Output is correct
22 Correct 81 ms 10936 KB Output is correct
23 Correct 92 ms 12256 KB Output is correct
24 Correct 88 ms 13628 KB Output is correct
25 Correct 87 ms 14996 KB Output is correct
26 Correct 83 ms 16764 KB Output is correct