Submission #106414

# Submission time Handle Problem Language Result Execution time Memory
106414 2019-04-18T11:12:23 Z BigChungus Hacker (BOI15_hac) C++14
0 / 100
2 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 && (!(x.first <= st)))
                        st = x.first;
                    else if (x.first > dr && (!(x.second >= dr)))
                        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 Incorrect 2 ms 384 KB Output isn't correct
2 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 Incorrect 2 ms 384 KB Output isn't correct
2 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 -