답안 #618097

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
618097 2022-08-01T22:17:04 Z BalintR 사탕 분배 (IOI21_candies) C++17
38 / 100
5000 ms 7372 KB
#include <vector>
using namespace std;
#pragma GCC target "avx2"
#pragma GCC optimize "Ofast"

typedef vector<int> vi;
#define SZ(v) ((int) (v).size())
#define min(a, b) ((a)<(b)?(a):(b))
#define max(a, b) ((a)<(b)?(b):(a))

const int MN = 2e5;
const int BSZ = 2e3;
int n, q;
int arr[BSZ], cap[BSZ];

vi distribute_candies(vi cIn, vi lIn, vi rIn, vi vIn){
    n = SZ(cIn);
    q = SZ(lIn);
    vi res(n);

    for(int bl = 0; bl < n; bl += BSZ){
        int br = min(n, bl+BSZ);
        for(int i = bl; i < br; i++) arr[i-bl] = 0, cap[i-bl] = cIn[i];

        for(int qi = 0; qi < q; qi++){
            int l = max(0, lIn[qi]-bl), r = min(br, rIn[qi]+1)-bl, v = vIn[qi];
            if(v < 0) for(int j = l; j < r; j++) arr[j] = max(arr[j] + v, 0);
            else for(int j = l; j < r; j++) arr[j] = min(arr[j] + v, cap[j]);
        }

        for(int i = bl; i < br; i++) res[i] = arr[i-bl];
    }

    return res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 ms 212 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2464 ms 7364 KB Output is correct
2 Correct 2425 ms 7372 KB Output is correct
3 Correct 2427 ms 7360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 68 ms 4956 KB Output is correct
3 Correct 65 ms 3796 KB Output is correct
4 Correct 2244 ms 7364 KB Output is correct
5 Correct 2281 ms 7360 KB Output is correct
6 Correct 2244 ms 7372 KB Output is correct
7 Correct 2162 ms 7360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 103 ms 5028 KB Output is correct
4 Correct 103 ms 2840 KB Output is correct
5 Execution timed out 5076 ms 7264 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 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 1 ms 212 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2464 ms 7364 KB Output is correct
7 Correct 2425 ms 7372 KB Output is correct
8 Correct 2427 ms 7360 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 68 ms 4956 KB Output is correct
11 Correct 65 ms 3796 KB Output is correct
12 Correct 2244 ms 7364 KB Output is correct
13 Correct 2281 ms 7360 KB Output is correct
14 Correct 2244 ms 7372 KB Output is correct
15 Correct 2162 ms 7360 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 103 ms 5028 KB Output is correct
19 Correct 103 ms 2840 KB Output is correct
20 Execution timed out 5076 ms 7264 KB Time limit exceeded
21 Halted 0 ms 0 KB -