# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
106398 |
2019-04-18T10:21:29 Z |
BigChungus |
Hacker (BOI15_hac) |
C++14 |
|
3 ms |
384 KB |
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int N = 5e5 + 7;
vector < pair < int, pair < int, int > > > sumemici;
int v[N], s[N];
int main()
{
int n;
cin >> n;
for (int i = 1; i <= n; ++i)
cin >> v[i];
for (int i = 1; i <= n; ++i)
s[i] = s[i - 1] + v[i];
for (int i = 1; i < (n + 1) / 2; ++i)
sumemici.push_back({s[n] - s[n / 2 + i] + s[i],{i + 1, n / 2 + i}});
sumemici.push_back({s[(n + 1) / 2], {(n + 1) / 2 + 1, n}});
sumemici.push_back({s[n] - s[n - (n + 1) / 2], {1, n - (n + 1) / 2}});
for (int i = (n + 1) / 2 + 1; i < n; ++i)
sumemici.push_back({s[i] - s[i - (n + 1) / 2], {i + 1, i - (n + 1) / 2}});
sort(sumemici.begin(), sumemici.end());
int st(1), dr(n);
for (auto i : sumemici) {
// cout << st << ' ' << dr << ' ' << i.first << ' ' << i.second.first << ' ' << i.second.second << '\n';
auto x = i.second;
if (x.second < x.first) {
if (st <= dr) {
if (st > x.second && dr < x.first)
return cout << i.first, 0;
if (st <= x.second && dr >= x.first) {
st = x.first;
dr = x.second;
///asta se poate intampla doar la inceput
}
else {
if (x.second <= st)
st = x.first;
else
dr = x.second;
}
}
else {///ambele au pe 1 si n deci nu se poate ca sa nu aiba intersectie(sa aiba int. vida)
st = max(st, x.first);
dr = min(dr, x.second);
}
}
else {
if (st <= dr) {
if (st > x.second || dr < x.first)
return cout << i.first, 0;
st = max(st, x.first);
dr = min(dr, x.second);
}
else {
if (x.first > dr && x.second < st)
return cout << i.first, 0;
if (dr <= x.first)
dr = x.second;
else
st = x.first;
}
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
3 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Incorrect |
3 ms |
256 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
3 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Incorrect |
3 ms |
256 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
0 ms |
256 KB |
Output is correct |
3 |
Correct |
3 ms |
332 KB |
Output is correct |
4 |
Correct |
2 ms |
256 KB |
Output is correct |
5 |
Correct |
2 ms |
256 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Incorrect |
3 ms |
256 KB |
Output isn't correct |
9 |
Halted |
0 ms |
0 KB |
- |