제출 #334026

#제출 시각아이디문제언어결과실행 시간메모리
334026ronnithHolding (COCI20_holding)C++14
22 / 110
2 ms364 KiB
#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;
}

컴파일 시 표준 에러 (stderr) 메시지

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...