Submission #835340

# Submission time Handle Problem Language Result Execution time Memory
835340 2023-08-23T13:30:28 Z azatega Distributing Candies (IOI21_candies) C++17
3 / 100
1704 ms 12108 KB
#include "candies.h"
#include <vector>

using namespace std;


vector<int> distribute_candies(vector<int> c, vector<int> l,
                                    vector<int> r, vector<int> v) {
    int n = c.size();
    vector<int> s(n);

    if(n <= 2000){
        for(int i = 0; i < n; i++){
            for(int j = 0; j < v.size(); j++){
                if(i >= l[j] && i <= r[j]){
                    s[i] += v[j];
                    s[i] = max(s[i], 0);
                    s[i] = min(s[i], c[i]);
                }
            }
        }

    }else{
        for(int j = 0; j < v.size(); j++){
            s[l[j]] += v[j];
            if(r[j] < n)
                s[r[j]] -= v[j];
        }

        int curr = 0;
        for(int i = 0; i < n; i++){
            curr += s[i];
            s[i] = curr;
        }
    }

    return s;
}

Compilation message

candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:14:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |             for(int j = 0; j < v.size(); j++){
      |                            ~~^~~~~~~~~~
candies.cpp:24:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |         for(int j = 0; j < v.size(); j++){
      |                        ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 7 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 78 ms 12108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1704 ms 8024 KB Output is correct
3 Incorrect 40 ms 6196 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 917 ms 7760 KB Output is correct
4 Incorrect 38 ms 4932 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 7 ms 340 KB Output is correct
6 Incorrect 78 ms 12108 KB Output isn't correct
7 Halted 0 ms 0 KB -