답안 #834719

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
834719 2023-08-22T17:39:02 Z JakobZorz 사탕 분배 (IOI21_candies) C++17
3 / 100
5000 ms 25764 KB
#include"candies.h"
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;

int n,days;

vector<int>vec;
void tree_init(){
    vec.resize(days);
}

void tree_add(int pos,int val){
    //for(int i=pos;i<days;i++)
        vec[pos]+=val;
}

int tree_get(int bound){
    int curr=0;
    for(int i=0;i<days;i++){
        curr+=vec[i];
        curr=max(0,min(bound,curr));
    }
    return curr;
}

vector<int>distribute_candies(vector<int>c,vector<int>l,vector<int>r,vector<int>v){
    n=(int)c.size();
    days=(int)v.size();
    vector<vector<pair<int,int>>>events;
    events.resize(n+1);
    
    for(int i=0;i<days;i++){
        events[l[i]].push_back({i,v[i]});
        events[r[i]+1].push_back({i,-v[i]});
    }
    
    vector<int>s(n);
    tree_init();
    
    for(int i=0;i<n;i++){
        for(auto event:events[i])
            tree_add(event.first,event.second);
        s[i]=tree_get(c[i]);
    }
    
    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 464 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 9 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 5045 ms 19812 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 786 ms 13348 KB Output is correct
3 Correct 776 ms 9716 KB Output is correct
4 Execution timed out 5048 ms 25764 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 785 ms 11620 KB Output is correct
4 Correct 775 ms 8680 KB Output is correct
5 Execution timed out 5026 ms 19372 KB Time limit exceeded
6 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 464 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 9 ms 468 KB Output is correct
6 Execution timed out 5045 ms 19812 KB Time limit exceeded
7 Halted 0 ms 0 KB -