# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
168575 |
2019-12-13T22:11:02 Z |
johutha |
Holiday (IOI14_holiday) |
C++14 |
|
64 ms |
7076 KB |
#include"holiday.h"
#include <vector>
#include <iostream>
#include <set>
#include <algorithm>
#include <cmath>
#define int long long
using namespace std;
struct Attractions
{
int n, totd;
int start;
vector<int> attraction;
int findMaxAttr(int lstart, int d)
{
multiset<int> active;
int cres = 0;
int pos;
for (pos = lstart; pos < lstart + d/2; pos++)
{
if (pos >= n) return cres;
cres += attraction[pos];
active.insert(attraction[pos]);
}
if (pos == n) return cres;
if (d % 2)
{
cres += attraction[pos];
active.insert(attraction[pos]);
pos++;
}
/*for (int i : active) cerr << i << " ";
cerr << "\n";
cerr << pos << "\n";*/
if (d % 2 == 0)
{
cres += attraction[pos];
active.insert(attraction[pos]);
cres -= *active.begin();
active.erase(active.begin());
pos++;
}
int mmax = cres;
for (; pos < n; pos++)
{
if (active.size() < 1) break;
cres += attraction[pos];
active.insert(attraction[pos]);
cres -= *active.begin();
active.erase(active.begin());
cres -= *active.begin();
active.erase(active.begin());
mmax = max(mmax, cres);
}
return mmax;
}
int solve()
{
return findMaxAttr(0, totd);
}
};
int findMaxAttraction(signed n, signed start, signed d, signed attraction[])
{
Attractions at;
at.n = n;
at.start = start + n;
at.totd = d;
for (int i = 0; i < n; i++)
{
at.attraction.push_back(attraction[i]);
}
return at.solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
256 KB |
Output is correct |
4 |
Correct |
2 ms |
380 KB |
Output is correct |
5 |
Incorrect |
2 ms |
376 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
64 ms |
6352 KB |
Output is correct |
2 |
Correct |
41 ms |
6376 KB |
Output is correct |
3 |
Correct |
42 ms |
6352 KB |
Output is correct |
4 |
Correct |
42 ms |
6380 KB |
Output is correct |
5 |
Correct |
45 ms |
4716 KB |
Output is correct |
6 |
Correct |
14 ms |
2036 KB |
Output is correct |
7 |
Correct |
26 ms |
3180 KB |
Output is correct |
8 |
Correct |
29 ms |
3184 KB |
Output is correct |
9 |
Correct |
11 ms |
1524 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
504 KB |
Output is correct |
2 |
Correct |
3 ms |
504 KB |
Output is correct |
3 |
Correct |
3 ms |
504 KB |
Output is correct |
4 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
46 ms |
6380 KB |
Output is correct |
2 |
Correct |
48 ms |
7076 KB |
Output is correct |
3 |
Incorrect |
12 ms |
1524 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |