Submission #128893

# Submission time Handle Problem Language Result Execution time Memory
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)
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 33 ms 376 KB Output is correct
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -
# Verdict Execution time Memory 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 -