# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
334026 | ronnith | Holding (COCI20_holding) | C++14 | 2 ms | 364 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>
typedef long long ll;
#define mk make_pair
#define f first
#define s second
using namespace std;
int main(){
int n, l, r, k;
scanf("%d%d%d%d", &n, &l, &r, &k);
int a[n];
for(int i = 0;i < n;i ++){
scanf("%d", &a[i]);
}
int ans = INT_MAX;
for(int bit = 0;bit < (1<<n);bit ++){
if(__builtin_popcount(bit) == n - l + 1){
int sm = 0;
int cost = 0;
int h = l;
for(int i = 0;i < n;i ++){
if(!((1<<i)&bit))continue;
cost += h - (i + 1);
h ++;
sm += a[i];
}
if(cost <= k){
ans = min(ans, sm);
}
}
}
printf("%d\n", ans);
return 0;
}
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... |