Submission #1010244

# Submission time Handle Problem Language Result Execution time Memory
1010244 2024-06-28T14:40:49 Z nickolasarapidis Distributing Candies (IOI21_candies) C++17
0 / 100
70 ms 13108 KB
#include "candies.h"
#include <bits/stdc++.h>
using namespace std;

#define ll long long

vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v){
	int N = c.size(), Q = l.size();
	
	vector<int> dif(N, 0);
	
	vector<int> S(N, 0);
	
	for(int i = 0; i < Q; i++){
		dif[l[i]] += v[i];
		dif[r[i] + 1] -= v[i];
	}
	
	if(c[0] >= dif[0] and dif[0] >= 0){
		S[0] = dif[0];
	}
	else if(c[0] < dif[0]){
		S[0] = c[0];
	}
	else if(dif[0] < 0){
		S[0] = 0;
	}
	
	for(int i = 1; i < N; i++){
		if(c[i] >= S[i - 1] + dif[i] and dif[i] >= 0){
			S[i] = S[i - 1] + dif[i];
		}
		else if(c[i] < S[i - 1] + dif[i]){
			S[i] = c[i];
		}
		else if(S[i - 1] + dif[i] < 0){
			S[i] = 0;
		}
	}
	
	return S;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 70 ms 13108 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -