답안 #614364

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
614364 2022-07-31T02:28:26 Z serize 사탕 분배 (IOI21_candies) C++17
3 / 100
103 ms 8032 KB
#include <candies.h>
#include <bits/stdc++.h>
#include <cassert>
#include <cstdio>
#include <vector>

using namespace std;
const int MAX = 2e5+10;

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();
    int q = l.size();
    std::vector<int> s(n);
    if(q <= 2000){
        for(int i = 0; i < q; i++){
            for(int j = l[i]; j <= r[i]; j++){
                if(v[i] < 0){
                    s[j] = max(0,s[j]+v[i]);
                }
                else{
                    s[j] = min(c[j],s[j]+v[i]);
                }
            }
        }
        return s;
    }
    std::vector<int> aux(n+10);
    for(int i = 0; i < q; i++){
        aux[l[i]] += v[i];
        aux[r[i]+1] -= v[i];
    }
    int sum = 0;
    for(int i = 0; i < n; i++){
        sum += aux[i];
        s[i] = min(c[i],sum);
    }
    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 1 ms 340 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 103 ms 8032 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 55 ms 4972 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 49 ms 4940 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 340 KB Output is correct
6 Incorrect 103 ms 8032 KB Output isn't correct
7 Halted 0 ms 0 KB -