답안 #570945

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
570945 2022-05-31T16:36:02 Z Vanilla 사탕 분배 (IOI21_candies) C++17
3 / 100
106 ms 8604 KB
#include <bits/stdc++.h>
using namespace std;
#define int64 long long
const int maxn = 2e5 + 3;
const int64 mod = 1e9 + 7;

vector <int> distribute_candies(vector <int> c, vector <int> l, vector <int> r, vector <int> v) {
    int n = c.size(), q = l.size();
    vector <int> cd (n + 3);
    if (n <= 2000 && q <= 2000){ // 1
        for (int i = 0; i < q; i++){
            for (int j = l[i]; j <= r[i]; j++){
                if (v[i] > 0) {
                    cd[j] = min(c[j], cd[j] + v[i]);
                }
                else cd[j] = max(0, cd[j] + v[i]);
            }
        }
    }
    else {
        for (int i = 0; i < q; i++){
            cd[l[i]]+=v[i];
            cd[r[i] + 1]-=v[i];
        }
        int64 sf = 0;
        for (int i = 0; i < n; i++){
            sf+=cd[i];
            cd[i] = min(cd[i], c[i]);
        }
    }
    vector <int> rt;
    for (int i = 0; i < n; i++){
        rt.push_back(cd[i]);
    }
    return rt;

}

// int main() {
//     vector <int> p1 = {10, 15, 20};
//     vector <int> p2 = {0, 2};
//     vector <int> p3 = {2, 2};
//     vector <int> p4 = {4, 9};
//     for (int i: distribute_candies(p1, p2, p3, p4)) {
//         cout << i << " ";
//     }
// }
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 106 ms 8604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 58 ms 6204 KB Output isn't correct
3 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 Incorrect 56 ms 6184 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 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
6 Incorrect 106 ms 8604 KB Output isn't correct
7 Halted 0 ms 0 KB -