Submission #832704

# Submission time Handle Problem Language Result Execution time Memory
832704 2023-08-21T14:05:16 Z gustason Fruits (NOI22_fruits) C++14
0 / 100
1000 ms 10192 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	
	int a[n], c[n];
	
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	
	for(int i = 0; i < n; i++) {
		cin >> c[i];
	}

	int order[n];
	iota(order, order+n, 1);
	vector<ll> ans(n);
	
	do {
		int curr = -1;
		ll val = 0;
		for(int i = 0; i < n; i++) {
			if (a[i] != -1 && order[i] != a[i]) {
				goto Out;
			}

			if (order[i] > curr) {
				curr = order[i];
				val += c[order[i]-1];
			}
			ans[i] = max(ans[i], val);
		}
	
		Out:;
	} while(next_permutation(order, order+n));

	for(auto& i : ans) {
		cout << i << " ";
	}
	cout << "\n";
}
# 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 Execution timed out 1077 ms 212 KB Time limit exceeded
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 Execution timed out 1048 ms 10192 KB Time limit exceeded
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 -