This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 = 0; mask < (1 << n); ++mask) {
long long sum = 0LL;
int first = start, last = start;
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) {
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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |