답안 #834775

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
834775 2023-08-22T19:10:05 Z Baytoro 사탕 분배 (IOI21_candies) C++17
3 / 100
90 ms 8908 KB
#include "candies.h"
//#include "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(x) x.begin(), x.end()

long long tree[1000005];
void add(int r, int v){
	r++;
	for(;r<400005;r+=r&-r){
		tree[r]+=v;
	}
}
void add(int l, int r, int v){
	add(r,v);
	if(l-1>=0)
		add(l-1,v);
}
int get(int x){
	x++;
	long long sum=0;
	for(;x>0;x-=x&-x)
		sum+=tree[x];
	return min(sum,1000000001ll);
}
int get(int r, int val){
	return get(r)-(r>0?get(r-1):0);
}
vector<int> distribute_candies(vector<int> c, vector<int> l,
                                    vector<int> r, vector<int> v) {
    int n=c.size(),q=v.size();
    vector<int> a(n);
    if(n<=2000 && q<=2000){
		for(int t=0;t<q;t++){
			for(int i=l[t];i<=r[t];i++){
				a[i]+=v[t];
				a[i]=min(c[i],a[i]);
				a[i]=max(a[i],0);
			}
		}
	}
	else{
		for(int t=0;t<q;t++){
			add(l[t],r[t],v[t]);
		}
		for(int i=0;i<n;i++)
			a[i]=max(c[i],get(i,0));
	}
	return a;
}
# 결과 실행 시간 메모리 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 1 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 90 ms 8908 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 51 ms 4980 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 43 ms 4940 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 1 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Incorrect 90 ms 8908 KB Output isn't correct
7 Halted 0 ms 0 KB -