제출 #114423

#제출 시각아이디문제언어결과실행 시간메모리
114423E869120휴가 (IOI14_holiday)C++14
47 / 100
145 ms2048 KiB
#include "holiday.h"
#include <bits/stdc++.h>
using namespace std;

long long e[109];

long long int findMaxAttraction(int n, int start, int d, int attraction[]) {
	if (n <= 3000) {
		long long maxn = 0;
		for (int i = 0; i <= start; i++) {
			priority_queue<long long, vector<long long>, greater<long long>>Q; long long s = 0;
			for (int j = i; j <= start - 1; j++) {
				Q.push(attraction[j]); s += 1LL * attraction[j];
				while (!Q.empty() && (int)Q.size() > d - (start - i)) { s -= Q.top(); Q.pop(); }
			}
			for (int j = start; j < n; j++) {
				s += attraction[j];
				Q.push(attraction[j]);
				int J = d - (j - i) - min(start - i, j - start);
				while (!Q.empty() && (int)Q.size() > J) { s -= Q.top(); Q.pop(); }
				maxn = max(maxn, s);
			}
		}
		return maxn;
	}
	long long maxn = 0;
	for (int i = 0; i < n; i++) {
		e[attraction[i]]++;
		long long s = 0, rem = d - i;
		for (int j = 100; j >= 0; j--) {
			if (rem >= e[j]) { rem -= e[j]; s += 1LL * e[j] * j; }
			else { s += 1LL * rem * j; rem = 0; }
		}
		maxn = max(maxn, s);
	}
	return maxn;
}

컴파일 시 표준 에러 (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...