Submission #106715

#TimeUsernameProblemLanguageResultExecution timeMemory
106715tincamatei휴가 (IOI14_holiday)C++14
23 / 100
71 ms1152 KiB
#include"holiday.h"
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 100000;
const long long INF = 1LL << 60;

int str[101];

long long getFirstK(int k) {
	long long sum = 0LL;
	for(int i = 100; i >= 0; --i) {
		if(str[i] <= k) {
			k -= str[i];
			sum += str[i] * i;
		} else {
			sum += i * k;
			k = 0;
		}
	}

	return sum;
}

long long int findMaxAttraction(int n, int start, int d, int _attraction[]) {
	long long rez = 0LL;
	if(n <= 20) {
		for(int mask = 1; mask < (1 << n); ++mask) {
			long long sum = 0LL;
			int first = n, last = 0;
			int used = 0;

			for(int j = 0; j < n; ++j)
				if((1 << j) & mask) {
					first = min(first, j);
					last = max(last, j);
					used++;
					sum += _attraction[j];
				}

			if(used + last - first + min(start - first, last - start) <= d && first <= start && start <= last) {
				rez = max(rez, sum);
			}
		}
	} else {
		rez = 0LL;
		for(int i = 0; i < n; ++i) {
			int k = d - i;
			str[_attraction[i]]++;
			rez = max(rez, getFirstK(k));
		}
	}

	return rez;
}

Compilation message (stderr)

grader.cpp: In function 'int main()':
grader.cpp:7:12: warning: variable 'n_s' set but not used [-Wunused-but-set-variable]
     int i, n_s;
            ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...