Submission #235400

# Submission time Handle Problem Language Result Execution time Memory
235400 2020-05-28T08:34:00 Z doowey Holding (COCI20_holding) C++14
22 / 110
6 ms 384 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int N = 105;
const int S = N * (N + 1);
const int M = S/2;
const int inf = (int)1e9;

int a[N];

int main(){
  fastIO;
  int n, l, r, k;
  cin >> n >> l >> r >> k;
  int ans = 0;
  for(int i = 1; i <= n; i ++ ){
    cin >> a[i];
    ans += (i >= l && i <= r) * a[i];
  }
  int s1 = l - 1;
  int s2 = n - l + 1;
  int sum;
  int cost;
  for(int i = 0 ; i < (1 << s2) ; i ++ ){
    for(int j = 0 ; j < (1 << s1) ; j ++ ){
      if(__builtin_popcount(i) != __builtin_popcount(j)) continue;
      sum = 0;
      cost = 0;
      for(int y = 0 ; y < s2; y ++ ){
        if((i & (1 << y))) cost += l + y;
        else sum += a[l + y];
      }
      for(int y = 0 ;y < s1; y ++ ){
        if((j & (1 << y))) {
          sum += a[1 + y];
          cost -= 1 + y;
        }
      }
      if(cost <= k)
        ans = min(ans, sum);
    }
  }
  cout << ans << "\n";
  return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Incorrect 6 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Incorrect 6 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Incorrect 6 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -