Submission #742847

# Submission time Handle Problem Language Result Execution time Memory
742847 2023-05-17T03:57:43 Z t6twotwo Distributing Candies (IOI21_candies) C++17
0 / 100
115 ms 13660 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[j], 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 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 115 ms 13660 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -