답안 #448012

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
448012 2021-07-28T13:39:24 Z aris12345678 사탕 분배 (IOI21_candies) C++17
11 / 100
5000 ms 13644 KB
#include <bits/stdc++.h>
#include "candies.h"
using namespace std;

const int mxN = 200005;

bool sub2(vector<int> v) {
    int q = int(v.size());
    for(int i = 0; i < q; i++) {
        if(v[i] < 0)
            return false;
    }
    return true;
}

vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
    int n = int(c.size()), q = int(l.size());
    vector<int> ans(n, 0);
    vector<long long> pref(n, 0);
    if(sub2(v)) {
        for(int i = 0; i < q; i++) {
            pref[l[i]] += 1LL*v[i];
            if(r[i] < n)
                pref[r[i]+1] -= 1LL*v[i];
        }
        for(int i = 0; i < n; i++) {
            if(i > 0)
                pref[i] += pref[i-1];
            if(pref[i] < c[i])
                ans[i] = pref[i];
            else
                ans[i] = c[i];
        }
    } else {
        for(int i = 0; i < q; i++) {
            for(int j = l[i]; j <= r[i]; j++) {
                if(v[i] > 0)
                    ans[j] = min(c[j], ans[j]+v[i]);
                else
                    ans[j] = max(0, ans[j]+v[i]);
            }
        }
    }
    return ans;
}
# 결과 실행 시간 메모리 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 3 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 131 ms 9692 KB Output is correct
2 Correct 121 ms 13644 KB Output is correct
3 Correct 119 ms 13520 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 243 ms 5716 KB Output is correct
3 Correct 226 ms 4292 KB Output is correct
4 Execution timed out 5085 ms 9644 KB Time limit exceeded
5 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 559 ms 5700 KB Output is correct
4 Correct 579 ms 4172 KB Output is correct
5 Execution timed out 5081 ms 9652 KB Time limit exceeded
6 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 3 ms 332 KB Output is correct
6 Correct 131 ms 9692 KB Output is correct
7 Correct 121 ms 13644 KB Output is correct
8 Correct 119 ms 13520 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 243 ms 5716 KB Output is correct
11 Correct 226 ms 4292 KB Output is correct
12 Execution timed out 5085 ms 9644 KB Time limit exceeded
13 Halted 0 ms 0 KB -