답안 #832745

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
832745 2023-08-21T14:21:08 Z gustason Fruits (NOI22_fruits) C++14
11 / 100
80 ms 16280 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll

signed 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];
	}
	
	if (n >= 9) {
		ll sum = 0;
		for(int i = n-1; i >= 0; i--) {
			sum += c[i];
			cout << sum << " ";
		}
		exit(0);
	}

	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;
			}
		}
		
		for(int i = 0; i < n; i++) {
			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";
	
	
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 5 ms 980 KB Output is correct
4 Correct 37 ms 8408 KB Output is correct
5 Correct 80 ms 16280 KB Output is correct
6 Correct 1 ms 280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Incorrect 0 ms 212 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Incorrect 0 ms 212 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 71 ms 9248 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 340 KB Output is correct
13 Correct 5 ms 980 KB Output is correct
14 Correct 37 ms 8408 KB Output is correct
15 Correct 80 ms 16280 KB Output is correct
16 Correct 1 ms 280 KB Output is correct
17 Incorrect 0 ms 212 KB Output isn't correct
18 Halted 0 ms 0 KB -