Submission #474240

# Submission time Handle Problem Language Result Execution time Memory
474240 2021-09-17T12:50:07 Z oliversommer Distributing Candies (IOI21_candies) C++17
0 / 100
134 ms 12856 KB
#include "candies.h"

#include <limits.h>

#include <algorithm>
#include <vector>

using namespace std;

vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
	int n = c.size();
	int q = l.size();
	vector<int> s(n);
	vector<int> lls(n);

	// queries
	for (int j = 0; j < q; ++j) {
		int left = l[j];
		int right = r[j];

		lls[left] += v[j];
		if (right < n - 1) {
			lls[right] -= v[j];
		}
	}

	// prefix sum
	for (int i = 1; i < n; ++i) {
		lls[i] = lls[i - 1];
	}

	// capacity
	for (int i = 0; i < n; ++i) {
		s[i] = min(max(lls[i], 0), c[i]);
	}

	return s;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 134 ms 12856 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -