Submission #620736

# Submission time Handle Problem Language Result Execution time Memory
620736 2022-08-03T08:39:24 Z MKopchev Distributing Candies (IOI21_candies) C++17
3 / 100
5000 ms 25172 KB
#include "candies.h"
#include<bits/stdc++.h>
using namespace std;

const int nmax=2e5+42;

vector< pair<int,int> > updates[nmax];

int given[nmax];

std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> l,
                                    std::vector<int> r, std::vector<int> v) {

    int n=c.size();

    int q=l.size();

    for(int j=0;j<q;j++)
    {
        updates[l[j]].push_back({j,v[j]});
        updates[r[j]+1].push_back({j,0});
    }

    vector<int> outp={};

    for(int i=0;i<n;i++)
    {
        for(auto w:updates[i])
            given[w.first]=w.second;

        int cur=0;

        for(int j=0;j<q;j++)
        {
            cur+=given[j];

            if(cur<0)cur=0;
            else if(cur>c[i])cur=c[i];
        }

        outp.push_back(cur);
    }

    return outp;
}

/*
int main() {
    int n;
    assert(1 == scanf("%d", &n));
    std::vector<int> c(n);
    for(int i = 0; i < n; ++i) {
        assert(scanf("%d", &c[i]) == 1);
    }

    int q;
    assert(1 == scanf("%d", &q));
    std::vector<int> l(q), r(q), v(q);
    for(int i = 0; i < q; ++i) {
        assert(scanf("%d %d %d", &l[i], &r[i], &v[i]) == 3);
    }

    std::vector<int> ans = distribute_candies(c, l, r, v);

    for(int i = 0; i < n; ++i) {
        if (i > 0) {
            printf(" ");
        }
        printf("%d", ans[i]);
    }
    printf("\n");
    fclose(stdout);
    return 0;
}
*/
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 4 ms 5052 KB Output is correct
4 Correct 4 ms 5148 KB Output is correct
5 Correct 13 ms 5152 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5088 ms 24112 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 632 ms 18092 KB Output is correct
3 Correct 647 ms 10952 KB Output is correct
4 Execution timed out 5013 ms 25172 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 4 ms 4948 KB Output is correct
3 Correct 1564 ms 13936 KB Output is correct
4 Correct 1657 ms 7892 KB Output is correct
5 Execution timed out 5058 ms 15536 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 4 ms 5052 KB Output is correct
4 Correct 4 ms 5148 KB Output is correct
5 Correct 13 ms 5152 KB Output is correct
6 Execution timed out 5088 ms 24112 KB Time limit exceeded
7 Halted 0 ms 0 KB -