답안 #553805

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
553805 2022-04-27T06:31:21 Z drdilyor 사탕 분배 (IOI21_candies) C++17
3 / 100
5000 ms 13276 KB
#include "candies.h"

#include <bits/stdc++.h>
#define vi vector<int>
#define ll long long
using namespace std;

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

    int allInc = 1;
    for (int i = 0; i < m; i++) {
        if (v[i] < 0) allInc = 0;
    }
    std::vector<int> s(n);

    if (allInc) {

        vi diff(n + 1);
        for (int i = 0; i < m; i++) {
            diff[l[i]] += v[i];
            diff[r[i]+1] -= v[i];
        }
        for (int i = 0, sum = 0; i < n; i++) {
            sum += diff[i];
            s[i] = max(sum, c[i]);
        }
    } else {
        for (int i = 0; i < m; i++) {
            for (int j = l[i]; j <= r[i]; j++) {
                s[j] = max(0, min(c[j], s[j] + v[i]));
            }
        }
    }
    return s;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 105 ms 8052 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 220 ms 8032 KB Output is correct
3 Correct 187 ms 5928 KB Output is correct
4 Execution timed out 5028 ms 13276 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 475 ms 7652 KB Output is correct
4 Correct 489 ms 4008 KB Output is correct
5 Execution timed out 5008 ms 10840 KB Time limit exceeded
6 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 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
6 Incorrect 105 ms 8052 KB Output isn't correct
7 Halted 0 ms 0 KB -