답안 #803138

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
803138 2023-08-02T23:11:42 Z vjudge1 사탕 분배 (IOI21_candies) C++17
11 / 100
82 ms 9276 KB
#include "candies.h"

#include <bits/stdc++.h>
using namespace std;
vector<int> distribute_candies(vector<int> c, vector<int> l,
                                    vector<int> r, vector<int> v) {
    int n = c.size(), q = l.size();
    if((long long)n*q < 5000000) {
        vector<int> s(n);
        for(int i = 0; i < q; i++)
            for(int j = l[i]; j <= r[i]; j++)
                if(v[i]>0)
                    s[j] = min(c[j], s[j]+v[i]);
                else
                    s[j] = max(0, s[j]+v[i]);
        return s;
    }
    vector<long long> s(n+1);
    for(int i = 0; i < q; i++)
        s[l[i]]+=v[i], s[r[i]+1]-=v[i];
    partial_sum(s.begin(), s.end(), s.begin());
    s.pop_back();
    vector<int> s2;
    for(int i = 0; i < n; i++)
        s2.push_back(min(s[i], (long long)c[i]));
    return s2;
}
# 결과 실행 시간 메모리 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 1 ms 340 KB Output is correct
5 Correct 3 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 82 ms 9184 KB Output is correct
2 Correct 77 ms 9276 KB Output is correct
3 Correct 76 ms 9268 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 45 ms 4956 KB Output isn't correct
3 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 Incorrect 41 ms 4972 KB Output isn't correct
4 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 1 ms 340 KB Output is correct
5 Correct 3 ms 364 KB Output is correct
6 Correct 82 ms 9184 KB Output is correct
7 Correct 77 ms 9276 KB Output is correct
8 Correct 76 ms 9268 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Incorrect 45 ms 4956 KB Output isn't correct
11 Halted 0 ms 0 KB -