# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1156593 | beaconmc | Team Coding (EGOI24_teamcoding) | C++20 | 1880 ms | 41304 KiB |
// not my code - I write better code than this
#include <bits/stdc++.h>
using namespace std;
const int X = 500;
int main() {
cin.tie(0)->sync_with_stdio(0);
int N, K;
cin >> N >> K;
/*
for each node u, the answer is:
- let the number of people on the i-th layer in the tree liking language l be b_li
- let the number of people on the i-th layer in the subtree of u be a_ui
- let the number of people in the subtree of u liking language L[u] be c_u
- ans[u][0] = sum of min(a_ui, b_li) for all i
- ans[u][1] = ans[0] - c_u
*/
/*
for each language:
- if number who prefer >= X:
-> at most N/X of these
-> run O(N log N) small to large algorithm
-> algorithm O(N log N * (N/X))
- if number who prefer < X
-> run O(X^2 log N) algorithm
-> so altogether is O(N/X * X^2 log N) = O(NX log N)
- so want N*N*logN/X = N*X*logN => N=X*X => X=sqrt(N) = 320
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |