답안 #743025

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
743025 2023-05-17T07:29:08 Z Mauve 사탕 분배 (IOI21_candies) C++17
11 / 100
196 ms 15044 KB
#include "candies.h"
using namespace std;
#include <bits/stdc++.h>
#define ll long long
int tree[1000000],C[200001];
void update(int node, int l, int r, int L, int R, int val){
	if(l>=L && r<=R){
		tree[node]=min(tree[node]+val,1000000007);
		return;
	}
	if(l>R || r<L) return;
	update(node*2,l,(l+r)/2,L,R,val);
	update(node*2+1,(l+r)/2+1,r,L,R,val);
}
int asuu(int node, int l, int r, int pos){
	if(l==r) return max(0,min(tree[node],C[pos]));
	if(pos<=(l+r)/2) return max(0,min(tree[node]+asuu(node*2,l,(l+r)/2,pos),C[pos]));
	else return max(0,min(tree[node]+asuu(node*2+1,(l+r)/2+1,r,pos),C[pos]));
}
vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v){
    int n = c.size(),q=l.size(),i,j,ii,jj,k,m;
	vector<int> s(n);
    for(i=1;i<=n;i++) C[i]=c[i-1];
    if(q<=2000){
    	for(i=0;i<q;i++){
    		for(j=l[i];j<=r[i];j++){
    			s[j]+=v[i];
    			if(s[j]<0) s[j]=0;
    			if(s[j]>c[j]) s[j]=c[j];
			}
		}
		return s;
	}
	for(i=0;i<q;i++) update(1,1,n,l[i]+1,r[i]+1,v[i]);
	for(i=1;i<=n;i++) s[i-1]=asuu(1,1,n,i);
	return s;
}

Compilation message

candies.cpp: In function 'std::vector<int> distribute_candies(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
candies.cpp:21:37: warning: unused variable 'ii' [-Wunused-variable]
   21 |     int n = c.size(),q=l.size(),i,j,ii,jj,k,m;
      |                                     ^~
candies.cpp:21:40: warning: unused variable 'jj' [-Wunused-variable]
   21 |     int n = c.size(),q=l.size(),i,j,ii,jj,k,m;
      |                                        ^~
candies.cpp:21:43: warning: unused variable 'k' [-Wunused-variable]
   21 |     int n = c.size(),q=l.size(),i,j,ii,jj,k,m;
      |                                           ^
candies.cpp:21:45: warning: unused variable 'm' [-Wunused-variable]
   21 |     int n = c.size(),q=l.size(),i,j,ii,jj,k,m;
      |                                             ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 308 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 3 ms 320 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 196 ms 15044 KB Output is correct
2 Correct 175 ms 14268 KB Output is correct
3 Correct 175 ms 13992 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 83 ms 8036 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 308 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 57 ms 7636 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 308 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 316 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 3 ms 320 KB Output is correct
6 Correct 196 ms 15044 KB Output is correct
7 Correct 175 ms 14268 KB Output is correct
8 Correct 175 ms 13992 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Incorrect 83 ms 8036 KB Output isn't correct
11 Halted 0 ms 0 KB -