답안 #596762

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
596762 2022-07-15T03:21:29 Z serize 사탕 분배 (IOI21_candies) C++17
3 / 100
110 ms 8052 KB
#include "candies.h"
#include <bits/stdc++.h>
#include <cassert>
#include <cstdio>
#include <vector>

using namespace std;

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);
    vector<int> abi(n+2);
    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]);
            }
        }
    }
    else{
        for(int i = 0; i < q; i++){
            int k = l[i]+1;
            while(k < (n+2) ){
                abi[k] += v[i];
                k += k&(-k);
            }
            k = r[i]+2;
            while(k < (n+2)){
                abi[k] += (-v[i]);
                k += k&(-k);
            }
        }
        for(int i = 0; i < n; i++){
            int x = 0, k = i+1;
            while(k > 0){
                x += abi[k];
                k -= k&(-k);
            }
            s[i] = min(c[i],x);
        }
    }
    return s;
}
# 결과 실행 시간 메모리 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 2 ms 340 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 110 ms 8052 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 56 ms 4960 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 58 ms 4964 KB Output isn't correct
4 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 2 ms 340 KB Output is correct
5 Correct 3 ms 340 KB Output is correct
6 Incorrect 110 ms 8052 KB Output isn't correct
7 Halted 0 ms 0 KB -