Submission #760530

# Submission time Handle Problem Language Result Execution time Memory
760530 2023-06-17T17:42:52 Z raysh07 The Big Prize (IOI17_prize) C++17
90 / 100
81 ms 2092 KB
#include "prize.h"
#include <bits/stdc++.h> 
using namespace std;

const int N = 2e5 + 69;
vector <int> a;
int f[N], mx;
int n;

void upd(int x){
    x++;
    for (int i = x; i <= n; i += i & (-i)) f[i]++;
}

int query(int x){
    x++;
    int res = 0;
    for (int i = x; i; i -= i & (-i)) res += f[i];
    return res;
}

void report(int x){
    upd(a[x]);
    a.erase(a.begin() + x);
}

int find(){
    int l = 0, r = a.size() - 1;
    
    while (l != r){
        // cout << l << " " << r << "\n";
        int m = (l + r)/2;
        
        auto g = ask(a[m]);
        int g1 = query(a[m]);
        
        // cout << m << " " << g[0] << " " << g1 << "\n";
        if (g[0] + g[1] < mx){
            if (g[0] + g[1] == 0) return a[m];
            report(m);
            return -1;
        }
        if (g1 < g[0]) {
            r = m - 1;
        } else {
            l = m + 1;
        }
    }
    
    // cout << l << " " << r << "\n";
    auto g = ask(a[l]);
    if (g[0] + g[1] == 0) return a[l];
    report(l);
    return -1;
}

int find_best(int m) {
    n = m;
    vector<vector<int>> ok;
	for (int i = 0; i < min(n, 500); i++){
	    auto get = ask(i);
	    ok.push_back(get);
	    
	    mx = max(mx, get[0] + get[1]);
	}
	
// 	if (mx != 1){
// 	    cout << n << "\n";
// 	    for (auto x : ok){
// 	        for (auto y : x) cout << y << " ";
// 	        cout << "\n";
// 	    }
// 	    return 0;
// 	}
	
	for (int i = 0; i < n; i++) a.push_back(i);
	
	while (true){
	    int get = find();
	    if (get > -1) return get;
	}
	assert(false);
	return 0;
}

// int main(){
//     // int t; cin >> t;
    
//     // while (t--){
//     //     int n = 3 + rand() % 10;
//     //     int x = rand() % n;
        
//     //     a.clear();
//     //     mx = 0;
//     //     for (int i = 0; i <= n; i++) f[i] = 0, a1[i] = a2[i] = 0;
        
//     //     for (int i = 0; i < x; i++) a2[i] = 1;
//     //     for (int i = x + 1; i < n; i++) a1[i] = 1;
        
//     //     int get = find_best(n);
//     //     if (get != x){
//     //         cout << n << " " << x << "\n";
//     //         return 0;
//     //     }
//     // }
    
//     int n; cin >> n;
//     for (int i = 0; i < n; i++) cin >> a1[i];
//     for (int i = 0; i < n; i++) cin >> a2[i];
    
//     cout << find_best(n);
//     return 0;
// }
# Verdict Execution time Memory Grader output
1 Correct 7 ms 1480 KB Output is correct
2 Correct 4 ms 1448 KB Output is correct
3 Correct 3 ms 1484 KB Output is correct
4 Correct 3 ms 1472 KB Output is correct
5 Correct 4 ms 1480 KB Output is correct
6 Correct 3 ms 1480 KB Output is correct
7 Correct 6 ms 1484 KB Output is correct
8 Correct 3 ms 1484 KB Output is correct
9 Correct 5 ms 1464 KB Output is correct
10 Correct 6 ms 1480 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1452 KB Output is correct
2 Correct 4 ms 1468 KB Output is correct
3 Correct 3 ms 1480 KB Output is correct
4 Correct 3 ms 1480 KB Output is correct
5 Correct 5 ms 1452 KB Output is correct
6 Correct 6 ms 1452 KB Output is correct
7 Correct 3 ms 1512 KB Output is correct
8 Correct 6 ms 1448 KB Output is correct
9 Correct 4 ms 1472 KB Output is correct
10 Correct 5 ms 1480 KB Output is correct
11 Correct 8 ms 1472 KB Output is correct
12 Correct 3 ms 1468 KB Output is correct
13 Correct 5 ms 1612 KB Output is correct
14 Correct 4 ms 592 KB Output is correct
15 Correct 13 ms 1472 KB Output is correct
16 Partially correct 39 ms 2012 KB Partially correct - number of queries: 7008
17 Correct 4 ms 1444 KB Output is correct
18 Partially correct 54 ms 1964 KB Partially correct - number of queries: 8347
19 Correct 4 ms 1480 KB Output is correct
20 Correct 20 ms 972 KB Output is correct
21 Correct 24 ms 1480 KB Output is correct
22 Correct 10 ms 1472 KB Output is correct
23 Correct 4 ms 1440 KB Output is correct
24 Correct 3 ms 1480 KB Output is correct
25 Correct 44 ms 1568 KB Output is correct
26 Correct 30 ms 1560 KB Output is correct
27 Correct 6 ms 1440 KB Output is correct
28 Partially correct 54 ms 1948 KB Partially correct - number of queries: 7905
29 Partially correct 43 ms 1920 KB Partially correct - number of queries: 6063
30 Partially correct 43 ms 2076 KB Partially correct - number of queries: 8257
31 Correct 5 ms 1484 KB Output is correct
32 Correct 7 ms 1480 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 27 ms 1472 KB Output is correct
35 Correct 7 ms 1480 KB Output is correct
36 Correct 21 ms 1496 KB Output is correct
37 Correct 6 ms 1452 KB Output is correct
38 Correct 5 ms 1444 KB Output is correct
39 Correct 17 ms 1556 KB Output is correct
40 Partially correct 46 ms 2020 KB Partially correct - number of queries: 7101
41 Correct 22 ms 1716 KB Output is correct
42 Correct 35 ms 1596 KB Output is correct
43 Correct 23 ms 1636 KB Output is correct
44 Correct 16 ms 1576 KB Output is correct
45 Correct 14 ms 1480 KB Output is correct
46 Correct 6 ms 1480 KB Output is correct
47 Correct 18 ms 1548 KB Output is correct
48 Partially correct 35 ms 1812 KB Partially correct - number of queries: 6077
49 Correct 12 ms 1444 KB Output is correct
50 Partially correct 53 ms 2060 KB Partially correct - number of queries: 8358
51 Correct 29 ms 1480 KB Output is correct
52 Correct 4 ms 1480 KB Output is correct
53 Correct 5 ms 1480 KB Output is correct
54 Correct 28 ms 1552 KB Output is correct
55 Correct 3 ms 1476 KB Output is correct
56 Partially correct 65 ms 2092 KB Partially correct - number of queries: 8371
57 Partially correct 25 ms 1816 KB Partially correct - number of queries: 5990
58 Partially correct 26 ms 1792 KB Partially correct - number of queries: 6087
59 Correct 47 ms 1692 KB Output is correct
60 Correct 22 ms 1584 KB Output is correct
61 Correct 4 ms 1436 KB Output is correct
62 Correct 5 ms 1448 KB Output is correct
63 Correct 7 ms 1464 KB Output is correct
64 Correct 6 ms 1440 KB Output is correct
65 Correct 9 ms 1472 KB Output is correct
66 Partially correct 36 ms 1476 KB Partially correct - number of queries: 5456
67 Correct 10 ms 1484 KB Output is correct
68 Correct 11 ms 1468 KB Output is correct
69 Partially correct 32 ms 1452 KB Partially correct - number of queries: 5306
70 Correct 6 ms 1508 KB Output is correct
71 Partially correct 62 ms 1948 KB Partially correct - number of queries: 8996
72 Correct 12 ms 1552 KB Output is correct
73 Partially correct 44 ms 1976 KB Partially correct - number of queries: 8870
74 Partially correct 80 ms 1980 KB Partially correct - number of queries: 8924
75 Correct 5 ms 1480 KB Output is correct
76 Partially correct 49 ms 1988 KB Partially correct - number of queries: 7700
77 Partially correct 81 ms 1964 KB Partially correct - number of queries: 8423
78 Correct 6 ms 1612 KB Output is correct
79 Correct 37 ms 2008 KB Output is correct
80 Partially correct 38 ms 1976 KB Partially correct - number of queries: 8440
81 Partially correct 77 ms 1928 KB Partially correct - number of queries: 8423
82 Partially correct 75 ms 1956 KB Partially correct - number of queries: 8379
83 Correct 6 ms 1452 KB Output is correct
84 Partially correct 68 ms 1968 KB Partially correct - number of queries: 6947
85 Partially correct 59 ms 1976 KB Partially correct - number of queries: 8440
86 Partially correct 44 ms 1484 KB Partially correct - number of queries: 5524
87 Correct 9 ms 1480 KB Output is correct
88 Partially correct 54 ms 1480 KB Partially correct - number of queries: 5281
89 Partially correct 40 ms 1468 KB Partially correct - number of queries: 5488
90 Correct 7 ms 1480 KB Output is correct
91 Correct 25 ms 1480 KB Output is correct
92 Partially correct 40 ms 1480 KB Partially correct - number of queries: 5299
93 Partially correct 59 ms 1480 KB Partially correct - number of queries: 5701
94 Partially correct 44 ms 1484 KB Partially correct - number of queries: 5716
95 Partially correct 54 ms 1452 KB Partially correct - number of queries: 5680
96 Partially correct 56 ms 1480 KB Partially correct - number of queries: 5645
97 Partially correct 57 ms 1484 KB Partially correct - number of queries: 5299