Submission #877987

# Submission time Handle Problem Language Result Execution time Memory
877987 2023-11-24T01:32:15 Z phong Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 2396 KB
#include <bits/stdc++.h>

#define int long long

using ll = long long;
const int nmax = 1e6 + 5;
const int lg = 20;
const int mod = 1e9 + 7;
const ll oo = 1e18;
#define fi first
#define se second
#define pii pair<int, int>
using namespace std;

int n, q, t;

double a[nmax], b[nmax];

bool check(int k){
    for(int i = 0; i <= n; ++i){
        int l = 0, r = n, it1 = -1, it2 = -1;
        while(l <= r){
            int mid = r + l >> 1;
            if(a[i] - i - mid >= k){
                it1 = mid;
                l = mid + 1;
            }
            else r = mid - 1;
        }
        if(it1 != -1){
//            cout << b[it1] - it1 - i << ' ' << k << "\n";
            if(a[i] - i - it1 >= k && b[it1] - it1 - i >= k) return 1;
        }
    }
    return 0;
}
 main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> a[i] >> b[i];
    sort(a + 1, a + 1 + n);
    sort(b + 1, b + 1 + n);
    for(int i = 1; i <= n; ++i){
        a[i] += a[i - 1];
        b[i] += b[i - 1];
    }
    int l = 0, r = 2e8, kq = -1;
    while(l <= r){
        int mid = r + l >> 1;
        if(check(mid)){
            kq = mid;
            l = mid + 1;
        }
        else r = mid - 1;
    }
    cout << kq << ' ';
}
/*
ai
*/

Compilation message

sure.cpp: In function 'bool check(long long int)':
sure.cpp:23:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   23 |             int mid = r + l >> 1;
      |                       ~~^~~
sure.cpp:21:37: warning: unused variable 'it2' [-Wunused-variable]
   21 |         int l = 0, r = n, it1 = -1, it2 = -1;
      |                                     ^~~
sure.cpp: At global scope:
sure.cpp:37:2: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   37 |  main(){
      |  ^~~~
sure.cpp: In function 'int main()':
sure.cpp:50:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   50 |         int mid = r + l >> 1;
      |                   ~~^~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Halted 0 ms 0 KB -