Submission #522699

# Submission time Handle Problem Language Result Execution time Memory
522699 2022-02-05T12:44:06 Z InternetPerson10 Distributing Candies (IOI21_candies) C++17
8 / 100
105 ms 15060 KB
#include "candies.h"
#include <vector>

using namespace std;
typedef long long ll;

vector<int> distribute_candies(vector<int> cInt, vector<int> lInt, vector<int> rInt, vector<int> vInt) {
    int n = cInt.size();
    vector<ll> s(n+1), c(n), l(n), r(n), v(vInt.size());
    for(int i = 0; i < n; i++) {
        l[i] = lInt[i];
        r[i] = rInt[i];
        c[i] = cInt[i];
    }
    for(int i = 0; i < v.size(); i++) {
        v[i] = vInt[i];
    }
    bool subtask2 = true, subtask3 = true, subtask4 = true;
    for(int i = 0; i < n; i++) {
        if(v[i] < 0) subtask2 = false;
        if(i > 0 && c[i] != c[i-1]) subtask3 = false;
        if(r[i] - l[i] != n-1) subtask4 = false;
    }
    int q = v.size();
    if(n <= 2000 && q <= 2000) { // Subtask 1
        for(int i = 0; i < q; i++) {
            for(int j = l[i]; j <= r[i]; j++) {
                s[j] += v[i];
                s[j] = max(s[j], 0LL);
                s[j] = min(s[j], c[j]);
            }
        }
    }
    else if(subtask2) {
        for(int i = 0; i < q; i++) {
            s[l[i]] += v[i];
            s[r[i]+1] -= v[i];
        }
        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]);
        }
    }
    else if(subtask3) {

    }
    else if(subtask4) {

    }
    else {

    }
    vector<int> sInt(n);
    for(int i = 0; i < n; i++) sInt[i] = s[i];
    return sInt;
}

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:15:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for(int i = 0; i < v.size(); i++) {
      |                    ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Runtime error 1 ms 716 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 105 ms 15044 KB Output is correct
2 Correct 98 ms 15056 KB Output is correct
3 Correct 88 ms 15060 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 51 ms 6596 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Incorrect 49 ms 9144 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Runtime error 1 ms 716 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -