Submission #871303

# Submission time Handle Problem Language Result Execution time Memory
871303 2023-11-10T13:50:14 Z TAhmed33 Weirdtree (RMI21_weirdtree) C++17
0 / 100
6 ms 2904 KB
#include <bits/stdc++.h>
#include <weirdtree.h>
using namespace std;
typedef long long ll;
int n;
ll arr[1001];
void initialise (int N, int q, int h[]) {
	n = N;
	for (int i = 1; i <= n; i++) {
		arr[i] = h[i];
	}
}
void cut (int l, int r, int k) {
	vector <pair <ll, ll>> dd;
	ll sum = 0;
	for (int i = l; i <= r; i++) {
		if (arr[i] < 0) exit(0);
		dd.push_back({arr[i], i});
		sum += arr[i];
	}
	if (sum <= k) {
		for (int i = l; i <= r; i++) arr[i] = 0;
		return;
	}
	sort(dd.begin(), dd.end(), [] (pair <ll, ll> &a, pair <ll, ll> &b) {
		return a.first == b.first ? a.second < b.second : a.first > b.first;
	});
	dd.push_back({0, (ll)1e9});
	for (int i = 1; i < (int)dd.size(); i++) {
		if (dd[i].first == dd[i - 1].first) continue;
		ll t = (dd[i - 1].first - dd[i].first) * i;
		if (t <= k) {
			k -= t;
			continue;
		}
		ll y = k / i;
		for (int j = 0; j < i; j++) arr[dd[j].second] = y;
		k -= y;
		for (int j = 0; j < k; j++) arr[dd[j].second]--;
		return;
	}	

}
void magic (int i, int x) {

}
ll inspect (int l, int r) {
	ll sum = 0;
	for (int i = l; i <= r; i++) {
		if (arr[i] < 0) exit(0);
		sum += arr[i];
	}
	return sum;
}
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 604 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 6 ms 2904 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -