답안 #500239

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
500239 2021-12-30T13:42:09 Z sazid_alam 사탕 분배 (IOI21_candies) C++17
11 / 100
432 ms 8900 KB
#include "candies.h"

#include <bits/stdc++.h>
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, 0);
    vector<long long int> sum(n + 1, 0);

    if(n < 2005){
        for(int i = 0; i < (int)v.size(); i++){
            for(int j = l[i]; j <= r[i]; j++){
                if(v[i] > 0) s[j] = min(c[j], s[j] + v[i]);
                else s[j] = max(0, s[j] + v[i]);
            }
        }
        return s;
    }
    else{
        for(int i = 0; i < (int)v.size(); i++){
            sum[l[i]] += v[i] * 1LL;
            sum[r[i] + 1] -= v[i] * 1LL;
        }

        for(int i = 1; i < n; i++) sum[i] += sum[i - 1];
        for(int i = 0; i < n; i++) c[i] = min(c[i] * 1LL, sum[i]);
        return c;
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 100 ms 8900 KB Output is correct
2 Correct 110 ms 8900 KB Output is correct
3 Correct 95 ms 8880 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 195 ms 5076 KB Output is correct
3 Incorrect 47 ms 4144 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 432 ms 5036 KB Output is correct
4 Incorrect 45 ms 4164 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 2 ms 332 KB Output is correct
6 Correct 100 ms 8900 KB Output is correct
7 Correct 110 ms 8900 KB Output is correct
8 Correct 95 ms 8880 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 195 ms 5076 KB Output is correct
11 Incorrect 47 ms 4144 KB Output isn't correct
12 Halted 0 ms 0 KB -