# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
620890 | dozer | Diversity (CEOI21_diversity) | C++14 | 2442 ms | 5676 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define sp " "
#define endl "\n"
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define N 300005
#define modulo 1000000007
#define int long long
const int INF = 2e18 + 7;
int arr[N], cnt[N];
int f(int sz, int n, int mask, int ind)
{
if (ind > sz) return 0;
int ans = INF;
for (int i = 0; i < n; i++)
{
if (mask & (1<<i)) continue;
int fin = ind + cnt[i + 1] - 1;
int tmp = (sz * (sz + 1)) / 2 - (((ind - 1) * ind) / 2 + ((sz - fin) * (sz - fin + 1)) / 2);
ans = min(ans, tmp + f(sz, n, mask | (1<<i), fin + 1));
}
return ans;
}
Compilation message (stderr)
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |