Submission #742849

# Submission time Handle Problem Language Result Execution time Memory
742849 2023-05-17T03:59:22 Z t6twotwo Distributing Candies (IOI21_candies) C++17
11 / 100
100 ms 12964 KB
#include "candies.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
std::vector<int> distribute_candies(std::vector<int> c, std::vector<int> l, std::vector<int> r, std::vector<int> v) {
	int n = c.size();
	int m = v.size();
	for (auto &x : r) {
		x++;
	}
	if (n <= 2000 && m <= 2000) {
		vector<int> a(n);
		for (int i = 0; i < m; i++) {
			for (int j = l[i]; j < r[i]; j++) {
				a[j] = min(c[j], max(a[j] + v[i], 0));
			}
		}
		return a;
	}
	if (*min_element(v.begin(), v.end()) > 0) {
		vector<ll> pfs(n + 1);
		for (int i = 0; i < m; i++) {
			pfs[l[i]] += v[i];
			pfs[r[i]] -= v[i];
		}
		for (int i = 0; i < n; i++) {
			pfs[i + 1] += pfs[i];
		}
		vector<int> a(n);
		for (int i = 0; i < n; i++) {
			a[i] = min(1LL * c[i], pfs[i]);
		}
		return a;
	}
	return {};
}
# Verdict Execution time Memory 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 6 ms 368 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 100 ms 8804 KB Output is correct
2 Correct 96 ms 12964 KB Output is correct
3 Correct 92 ms 12848 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 53 ms 4956 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Incorrect 51 ms 4952 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 6 ms 368 KB Output is correct
6 Correct 100 ms 8804 KB Output is correct
7 Correct 96 ms 12964 KB Output is correct
8 Correct 92 ms 12848 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Incorrect 53 ms 4956 KB Output isn't correct
11 Halted 0 ms 0 KB -