Submission #742848

# Submission time Handle Problem Language Result Execution time Memory
742848 2023-05-17T03:58:18 Z t6twotwo Distributing Candies (IOI21_candies) C++17
3 / 100
113 ms 8808 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 + 1]);
		}
		return a;
	}
	return {};
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 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 7 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 113 ms 8808 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 55 ms 8016 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 7644 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 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 7 ms 340 KB Output is correct
6 Incorrect 113 ms 8808 KB Output isn't correct
7 Halted 0 ms 0 KB -