| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1367528 | rana_azka | Subset Mex (EGOI22_subsetmex) | C++20 | 1 ms | 344 KiB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e18;
const int MOD = 1e9+7;
const int MAXN = 50;
int n, m;
int arr[MAXN+5];
int need[MAXN+5];
void solve(){
cin >> n;
for(int i = 0; i < n; i++) cin >> arr[i];
need[n-1] = 1;
for(int i = n - 1 - 1; i >= 0; i--) need[i] = need[i+1] * 2;
for(int i = n - 1; i >= 0; i--){
int diff = need[i] - max(need[i] - arr[i], 0ll);
// cerr << i << " : " << diff << endl;
need[i] -= diff;
int temp = 1;
for(int j = i - 1; j >= 0; j--){
need[j] -= temp * diff;
temp *= 2;
}
}
int ans = 1;
for(int i = 0; i <= n - 1; i++) ans += need[i];
// cerr << "=> ";
cout << ans << endl;
// for(int i = 0; i <= n - 1; i++) cerr << need[i] << ' ';
// cerr << endl;
}
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int tc = 1;
cin >> tc;
while(tc--){
solve();
}
return 0;
}
/*
2
4
0 3 0 3
5
4 1 0 2 0
*/| # | 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... | ||||
