Submission #1055386

# Submission time Handle Problem Language Result Execution time Memory
1055386 2024-08-12T18:36:07 Z mariaclara Distributing Candies (IOI21_candies) C++17
3 / 100
53 ms 8184 KB
#include "candies.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mk make_pair
#define pb push_back
#define fr first
#define sc second

vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
    int n = sz(c), q = sz(l);
    vector<int> ans(n);

    if(n <= 2000 and q <= 2000) {
        for(int Q = 0; Q < q; Q++) {
            for(int i = l[Q]; i <= r[Q]; i++)
                ans[i] = min(max(0, ans[i] + v[Q]), c[i]);
        }
    }
    else {
        vector<int> p(n+1);

        for(int Q = 0; Q < q; Q++) {
            p[l[Q]] += v[Q];
            p[r[Q]+1] -= v[Q];
        }

        for(int i = 0; i < n; i++) {
            if(i > 0) p[i] += p[i-1];
            ans[i] = min(c[i], p[i]);
        }
    }

    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 53 ms 8184 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 32 ms 5120 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Incorrect 28 ms 5104 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 3 ms 348 KB Output is correct
6 Incorrect 53 ms 8184 KB Output isn't correct
7 Halted 0 ms 0 KB -