제출 #1063750

#제출 시각아이디문제언어결과실행 시간메모리
1063750pawned휴가 (IOI14_holiday)C++17
7 / 100
5081 ms2840 KiB
#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")

#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;

#include "holiday.h"

ll findMaxAttraction(int N, int start, int D, int attraction[]) {
	vi a;
	for (int i = 0; i < N; i++) {
		a.pb(attraction[i]);
	}
	ll maximum = 0;
	for (int i = 1; i < (1 << N); i++) {	// get this subset
		ll total = 0;
		int lb = N + 1;
		int ub = -1;
		int cnt = 0;
		for (int j = 0; j < N; j++) {
			if (i & (1 << j)) {
				lb = min(lb, j);
				ub = max(ub, j);
				total += a[j];
				cnt++;
			}
		}
		int days = (start - lb) + (ub - start) + min(start - lb, ub - start);
		if (lb <= ub && ub <= start)
			days = start - lb;
		if (start <= lb && lb <= ub)
			days = ub - start;
		days += cnt;
		if (days <= D)
			maximum = max(maximum, total);
	}
	return maximum;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...