Submission #62706

# Submission time Handle Problem Language Result Execution time Memory
62706 2018-07-29T21:20:24 Z eriksuenderhauf Sure Bet (CEOI17_sure) C++11
0 / 100
3 ms 376 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("%f", &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);
    }
    long double tmp = ans / 10000.;
    printf("%.4lf", tmp);
    return 0;
}

Compilation message

sure.cpp: In function 'int main()':
sure.cpp:10:29: warning: format '%f' expects argument of type 'float*', but argument 2 has type 'double*' [-Wformat=]
 #define nl(n) scanf("%f", &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);
         ~~~~                 
sure.cpp:37:9: note: in expansion of macro 'nl'
         nl(x), nl(y);
         ^~
sure.cpp:10:29: warning: format '%f' expects argument of type 'float*', but argument 2 has type 'double*' [-Wformat=]
 #define nl(n) scanf("%f", &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);
         ~~~~~~~~~~~          
sure.cpp:37:16: note: in expansion of macro 'nl'
         nl(x), nl(y);
                ^~
sure.cpp:61:24: warning: format '%lf' expects argument of type 'double', but argument 2 has type 'long double' [-Wformat=]
     printf("%.4lf", tmp);
                        ^
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]
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Incorrect 3 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Incorrect 3 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Incorrect 3 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -