Submission #1053214

# Submission time Handle Problem Language Result Execution time Memory
1053214 2024-08-11T09:47:48 Z noyancanturk Distributing Candies (IOI21_candies) C++17
3 / 100
62 ms 7404 KB
#include "candies.h"

#include <bits/stdc++.h>
using namespace std;

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(),m=r.size();
    if(n<=4000&&m<=4000){
        std::vector<int> s(n);
        for(int i=0;i<m;i++){
            for(int j=l[i];j<=r[i];j++){
                s[j]+=v[i];
                s[j]=min(c[j],max(0,s[j]));
            }
        }
        return s;
    }
    vector<int>s(n+1);
    for(int i=0;i<m;i++){
        s[l[i]]+=v[i];
        s[r[i]+1]-=v[i];
    }
    s.pop_back();
    for(int i=1;i<n;i++){
        s[i]+=s[i-1];
    }
    for(int i=0;i<n;i++){
        s[i]=min(s[i],c[i]);
    }
    return s;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 62 ms 7404 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 27 ms 4948 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 0 ms 344 KB Output is correct
3 Incorrect 26 ms 5112 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 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 1 ms 348 KB Output is correct
6 Incorrect 62 ms 7404 KB Output isn't correct
7 Halted 0 ms 0 KB -