| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1361968 | avahw | Subset Mex (EGOI22_subsetmex) | C++20 | 1 ms | 352 KiB |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll min_moves(vector<ll>& amounts){
ll n = amounts.size();
vector<ll> needed(n, 1);
// to start, we will need at least 1 of each kind of number
for(ll i = n - 1; i >= 0; i--){
if(needed[i] <= amounts[i]) continue;
// otherwise we need diff of every other element
for(ll j = i - 1; j >= 0; j--){
needed[j] += needed[i] - amounts[i];
}
}
ll res = 1;
for(ll i = 0; i < n; i++){
res += max(0LL, needed[i] - amounts[i]);
}
return res;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(0);
ll t;
cin >> t;
for(ll _ = 0; _ < t; _++){
ll n;
cin >> n;
vector<ll> amounts(n);
for(ll i = 0; i < n; i++) cin >> amounts[i];
cout << min_moves(amounts) << "\n";
}
}| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
