QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#345245 | #7933. Build Permutation | yby | TL | 1ms | 4644kb | C99 | 933b | 2024-03-06 17:34:35 | 2024-03-06 17:34:36 |
Judging History
answer
#include <stdio.h>
#define N 200007
typedef struct {
int vl;
int id;
} seg;
int main() {
int n;
scanf("%d", &n);
seg b[N];
int a[N];
for (int i = 1; i <= n; i++) {
scanf("%lld", &b[i].vl);
b[i].id = i;
a[i] = b[i].vl;
}
for (int i = 1; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
if (b[i].vl > b[j].vl) {
seg temp = b[i];
b[i] = b[j];
b[j] = temp;
}
}
}
int ans[N];
for (int i = 1; i <= n; i++) {
ans[b[i].id] = b[n - i + 1].id;
}
int vp = a[1] + a[ans[1]];
for (int i = 1; i <= n; i++) {
if (a[i] + a[ans[i]] != vp) {
printf("-1\n");
return 0;
}
}
for (int i = 1; i <= n; i++) {
printf("%d ", ans[i]);
}
printf("\n");
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4636kb
input:
5 4 2 5 1 3
output:
2 1 4 3 5
result:
ok
Test #2:
score: 0
Accepted
time: 1ms
memory: 4644kb
input:
3 2 2 3
output:
-1
result:
ok
Test #3:
score: -100
Time Limit Exceeded
input:
199528 581552649 419782901 924554494 589802859 878336763 659984178 419820729 521791999 956262027 523946290 442086405 808419260 875183942 860794919 584899704 494193909 687014591 794119827 641706288 734029639 795387770 803653459 889799156 455122734 655375888 757642629 427654115 987811208 593072829 584...