답안 #813758

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
813758 2023-08-08T03:21:37 Z PixelCat 사탕 분배 (IOI21_candies) C++17
3 / 100
5000 ms 14028 KB
#include "candies.h"

#ifdef NYAOWO
#include "grader.cpp"
#endif

#include <bits/stdc++.h>
#define For(i, a, b) for(int i = a; i <= b; i++)
#define Forr(i, a, b) for(int i = a; i >= b; i--)
#define F first
#define S second
#define sz(x) ((int)x.size())
#define all(x) x.begin(), x.end()
#define eb emplace_back
// #define int LL
using namespace std;
using i32 = int32_t;
using LL = long long;
using pii = pair<int, int>;

const int MAXN = 2000;

vector<i32> distribute_candies(vector<i32> C, vector<i32> L, vector<i32> R, vector<i32> V) {
    int n = sz(C);
    int q = sz(L);
    vector<int> ans(n);
    For(i, 0, n - 1) {
        int c = C[i];
        vector<int> add(q);
        For(j, 0, q - 1) {
            if(L[j] <= i && i <= R[j]) {
                add[j] = -V[j];
            }
        }
        int mx = 0, mn = 0, cur = 0;
        Forr(j, q - 1, 0) {
            int nmx = max(mx, cur + add[j]);
            int nmn = min(mn, cur + add[j]);
            if(nmx - nmn > c) {
                if(add[j] < 0) ans[i] = c - mx;
                else ans[i] = -mn;
                goto DONE;
            }
            cur += add[j];
            mx = nmx;
            mn = nmn;
        }
        ans[i] = -mn;
        DONE:;
    }
    return ans;
}

/*

3
10 15 13
2
0 2 20
0 1 -11

0 4 13

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 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 8 ms 420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5075 ms 12880 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 KB Output is correct
2 Correct 2086 ms 8820 KB Output is correct
3 Correct 1047 ms 5984 KB Output is correct
4 Execution timed out 5054 ms 14028 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 296 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 546 ms 8408 KB Output is correct
4 Correct 549 ms 4016 KB Output is correct
5 Execution timed out 5048 ms 11596 KB Time limit exceeded
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 304 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 8 ms 420 KB Output is correct
6 Execution timed out 5075 ms 12880 KB Time limit exceeded
7 Halted 0 ms 0 KB -