Submission #112173

# Submission time Handle Problem Language Result Execution time Memory
112173 2019-05-17T17:25:10 Z Pajaraja Sure Bet (CEOI17_sure) C++17
100 / 100
81 ms 5368 KB
#include <bits/stdc++.h>
using namespace std;
double a[100001],b[100001],sa[100001],sb[100001];
int main() 
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++) scanf("%lf%lf",&a[i],&b[i]);
    sort(a,a+n,greater<double>());
    sort(b,b+n,greater<double>());
    double sol=0;
    for(int i=1;i<=n;i++) sa[i]=sa[i-1]+a[i-1];
    for(int i=1;i<=n;i++) sb[i]=sb[i-1]+b[i-1];
    int t1=0,t2=0;
    while(t1<=n && t2<=n)
    {
        double a;
        if(sb[t2]-t1-t2>sa[t1]-t1-t2) a=sa[t1]-t1-t2;
        else a=sb[t2]-t1-t2;
        if(sol<a) sol=a;
        if(sa[t1]<sb[t2]) t1++;
        else t2++;
    }
    printf("%.4lf",sol);
    return 0;
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
sure.cpp:8:31: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<n;i++) scanf("%lf%lf",&a[i],&b[i]);
                          ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 3 ms 384 KB Output is correct
14 Correct 2 ms 384 KB Output is correct
15 Correct 3 ms 384 KB Output is correct
16 Correct 3 ms 384 KB Output is correct
17 Correct 62 ms 4848 KB Output is correct
18 Correct 66 ms 4888 KB Output is correct
19 Correct 81 ms 4844 KB Output is correct
20 Correct 65 ms 4972 KB Output is correct
21 Correct 68 ms 5368 KB Output is correct
22 Correct 67 ms 4908 KB Output is correct
23 Correct 65 ms 4856 KB Output is correct
24 Correct 63 ms 4828 KB Output is correct
25 Correct 62 ms 4856 KB Output is correct
26 Correct 65 ms 5240 KB Output is correct