Submission #334026

# Submission time Handle Problem Language Result Execution time Memory
334026 2020-12-08T06:36:58 Z ronnith Holding (COCI20_holding) C++14
22 / 110
2 ms 364 KB
#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

holding.cpp: In function 'int main()':
holding.cpp:12:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |  scanf("%d%d%d%d", &n, &l, &r, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
holding.cpp:15:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |   scanf("%d", &a[i]);
      |   ~~~~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Incorrect 2 ms 364 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Incorrect 2 ms 364 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Incorrect 2 ms 364 KB Output isn't correct
9 Halted 0 ms 0 KB -