답안 #435496

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
435496 2021-06-23T11:30:12 Z kshitij_sodani 사탕 분배 (IOI21_candies) C++17
8 / 100
167 ms 10844 KB
#include <bits/stdc++.h>
using namespace std;
#define a first
#define b second
#define pb push_back
typedef long long llo;

#include "candies.h"

#include <vector>
llo cur[200001];
llo tree[200001];
void u(llo i,llo j){
	while(i<=200000){
		tree[i]+=j;
		i+=(i&-i);
	}
}
llo ss(llo i){
	llo su=0;
	while(i>0){
		su+=tree[i];
		i-=(i&-i);
	}
	return su;
}
std::vector<int> distribute_candies(vector<int> it,vector<int> ll,
                                    vector<int> rr,vector<int> aa) {
    
	llo n=it.size();
	llo q=ll.size();
	for(llo i=0;i<n;i++){
		cur[i]=0;
	}
	for(llo i=0;i<=200000;i++){
		tree[i]=0;
	}
	for(llo i=0;i<q;i++){
		u(ll[i]+1,aa[i]);
		u(rr[i]+2,-aa[i]);
		/*for(llo j=ll[i];j<=rr[i];j++){
			cur[j]+=aa[i];
			cur[j]=max(cur[j],0);
			cur[j]=min(cur[j],it[j]);
		}*/
	}
	vector<int> ans;
	for(llo i=0;i<n;i++){
		ans.pb((int)min((llo)it[i],ss(i+1)));
		//cout<<ss(i+1)<<":";
	}
	//cout<<endl;










    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1740 KB Output is correct
2 Incorrect 1 ms 1868 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 167 ms 10812 KB Output is correct
2 Correct 141 ms 10844 KB Output is correct
3 Correct 128 ms 10808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1868 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 1868 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 1740 KB Output is correct
2 Incorrect 1 ms 1868 KB Output isn't correct
3 Halted 0 ms 0 KB -