Submission #712351

# Submission time Handle Problem Language Result Execution time Memory
712351 2023-03-18T16:24:20 Z danikoynov Distributing Candies (IOI21_candies) C++17
0 / 100
5000 ms 28144 KB
#include "candies.h"

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10;
const ll inf = 1e18;

int n, q;

vector < int > s;
ll pref[maxn];
vector < int > add[maxn], rem[maxn];
vector<int> distribute_candies(vector<int> c, vector<int> l,
                               vector<int> r, vector<int> v)
{
    n = c.size();
    q = l.size();
    s.resize(n, 0);
    for (int i = 0; i < q; i ++)
    {
        add[l[i]].push_back(i);
        rem[r[i]].push_back(i);
    }

    for (int i = 0; i < n; i ++)
    {

        pref[0] = inf;
        pref[1] = 0;
        for (int j = 0; j < q; j ++)
        {
            pref[j + 2] = pref[j + 1];
            if (l[j] <= i && r[j] >= i)
                pref[j] += v[j];
        }

        ll max_height = pref[q + 1];
        ll min_height = pref[q + 1];
        int last = q + 1;
        for (int j = q; j >= 0; j --)
        {
            max_height = max(max_height, pref[j]);
            min_height = min(min_height, pref[j]);
            last = j;
            if (max_height - min_height > c[i])
                break;
        }
        if (max_height == pref[last])
            s[i] = pref[q + 1] - min_height;
        else
            s[i] = pref[q + 1] - (max_height - c[i]);

    }

    return s;
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 9684 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5017 ms 28144 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 9684 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 9684 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 9684 KB Output isn't correct
2 Halted 0 ms 0 KB -