Submission #106396

#TimeUsernameProblemLanguageResultExecution timeMemory
106396BigChungusHacker (BOI15_hac)C++14
20 / 100
181 ms12652 KiB
#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 + 1) / 2 + i] + s[i],{n / 2 + i + 1, i}}); for (int i = (n + 1) / 2; i <= n; ++i) sumemici.push_back({s[i] - s[i - (n + 1) / 2], {i - n / 2 + 1, i}}); 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...