답안 #128893

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
128893 2019-07-11T10:43:37 Z E869120 Permutation Recovery (info1cup17_permutation) C++14
25 / 100
76 ms 376 KB
#include <iostream>
using namespace std;
#pragma warning (disable: 4996)

long long N, P[100009], A[100009];

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) cin >> P[i];
	for (int i = N; i >= 1; i--) P[i] = (P[i] - P[i - 1]);
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= i; j++) {
			long long s = 1;
			for (int k = 1; k < i; k++) {
				if (A[k] <= j) s += P[k];
			}
			if (s == P[i]) {
				A[i] = j + 1;
				for (int k = 1; k < i; k++) { if (A[k] > j) A[k]++; }
				break;
			}
		}
	}
	for (int i = 1; i <= N; i++) { if (i >= 2) cout << " "; cout << A[i]; } cout << endl;
	return 0;
}

Compilation message

permutation.cpp:3:0: warning: ignoring #pragma warning  [-Wunknown-pragmas]
 #pragma warning (disable: 4996)
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 33 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 33 ms 376 KB Output is correct
3 Incorrect 76 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 33 ms 376 KB Output is correct
3 Incorrect 76 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 33 ms 376 KB Output is correct
3 Incorrect 76 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 33 ms 376 KB Output is correct
3 Incorrect 76 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 33 ms 376 KB Output is correct
3 Incorrect 76 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 33 ms 376 KB Output is correct
3 Incorrect 76 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -