답안 #835349

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
835349 2023-08-23T13:37:33 Z azatega 사탕 분배 (IOI21_candies) C++17
11 / 100
1594 ms 12868 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{
        vector<long long> ch(n+5);

        for(int j = 0; j < v.size(); j++){
            ch[l[j]] += v[j];
            ch[r[j] + 1] -= v[j];
        }

        long long curr = 0;
        for(int i = 0; i < n; i++){
            curr += ch[i];
            s[i] = min((long long)c[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:26:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for(int j = 0; j < v.size(); j++){
      |                        ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 7 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 74 ms 8860 KB Output is correct
2 Correct 75 ms 12868 KB Output is correct
3 Correct 118 ms 12748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1594 ms 5016 KB Output is correct
3 Incorrect 42 ms 4148 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 919 ms 5012 KB Output is correct
4 Incorrect 38 ms 4152 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 2 ms 212 KB Output is correct
5 Correct 7 ms 340 KB Output is correct
6 Correct 74 ms 8860 KB Output is correct
7 Correct 75 ms 12868 KB Output is correct
8 Correct 118 ms 12748 KB Output is correct
9 Correct 1 ms 256 KB Output is correct
10 Correct 1594 ms 5016 KB Output is correct
11 Incorrect 42 ms 4148 KB Output isn't correct
12 Halted 0 ms 0 KB -