Submission #58557

# Submission time Handle Problem Language Result Execution time Memory
58557 2018-07-18T07:11:05 Z gusfring Xylophone (JOI18_xylophone) C++14
100 / 100
125 ms 844 KB
#include "xylophone.h"
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 5e3 + 5;

int A[MAXN], dif[MAXN];

void solve(int N){ 
  for(int i=1; i<N; ++i) dif[i - 1] = query(i, i + 1);
  int sign = 1;
  A[0] = 0, A[1] = dif[0];
  for(int i=1; i<N-1; ++i){
    if(query(i, i + 2) != (dif[i - 1] + dif[i])) sign = -sign;
    A[i + 1] = A[i] + sign * dif[i];
  }
  int mn = 0, mx = 0;
	for(int i=1; i<N; ++i){
    if(A[i] < A[mn]) mn = i;
    if(A[i] > A[mx]) mx = i;
  }
  if(mn > mx){
    for(int i=1; i<N; ++i) A[i] = -A[i];
    swap(mn, mx);
  }
  for(int i=0; i<N; ++i) answer(i + 1, A[i] - A[mn] + 1);
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 388 KB Output is correct
2 Correct 2 ms 388 KB Output is correct
3 Correct 4 ms 388 KB Output is correct
4 Correct 3 ms 408 KB Output is correct
5 Correct 3 ms 420 KB Output is correct
6 Correct 4 ms 624 KB Output is correct
7 Correct 4 ms 624 KB Output is correct
8 Correct 4 ms 624 KB Output is correct
9 Correct 4 ms 624 KB Output is correct
10 Correct 3 ms 624 KB Output is correct
11 Correct 3 ms 624 KB Output is correct
12 Correct 5 ms 624 KB Output is correct
13 Correct 5 ms 624 KB Output is correct
14 Correct 4 ms 624 KB Output is correct
15 Correct 3 ms 624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 388 KB Output is correct
2 Correct 2 ms 388 KB Output is correct
3 Correct 4 ms 388 KB Output is correct
4 Correct 3 ms 408 KB Output is correct
5 Correct 3 ms 420 KB Output is correct
6 Correct 4 ms 624 KB Output is correct
7 Correct 4 ms 624 KB Output is correct
8 Correct 4 ms 624 KB Output is correct
9 Correct 4 ms 624 KB Output is correct
10 Correct 3 ms 624 KB Output is correct
11 Correct 3 ms 624 KB Output is correct
12 Correct 5 ms 624 KB Output is correct
13 Correct 5 ms 624 KB Output is correct
14 Correct 4 ms 624 KB Output is correct
15 Correct 3 ms 624 KB Output is correct
16 Correct 3 ms 624 KB Output is correct
17 Correct 13 ms 624 KB Output is correct
18 Correct 18 ms 624 KB Output is correct
19 Correct 20 ms 624 KB Output is correct
20 Correct 22 ms 624 KB Output is correct
21 Correct 21 ms 624 KB Output is correct
22 Correct 17 ms 624 KB Output is correct
23 Correct 20 ms 624 KB Output is correct
24 Correct 22 ms 624 KB Output is correct
25 Correct 21 ms 624 KB Output is correct
26 Correct 20 ms 624 KB Output is correct
27 Correct 16 ms 624 KB Output is correct
28 Correct 16 ms 624 KB Output is correct
29 Correct 17 ms 624 KB Output is correct
30 Correct 18 ms 624 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 388 KB Output is correct
2 Correct 2 ms 388 KB Output is correct
3 Correct 4 ms 388 KB Output is correct
4 Correct 3 ms 408 KB Output is correct
5 Correct 3 ms 420 KB Output is correct
6 Correct 4 ms 624 KB Output is correct
7 Correct 4 ms 624 KB Output is correct
8 Correct 4 ms 624 KB Output is correct
9 Correct 4 ms 624 KB Output is correct
10 Correct 3 ms 624 KB Output is correct
11 Correct 3 ms 624 KB Output is correct
12 Correct 5 ms 624 KB Output is correct
13 Correct 5 ms 624 KB Output is correct
14 Correct 4 ms 624 KB Output is correct
15 Correct 3 ms 624 KB Output is correct
16 Correct 3 ms 624 KB Output is correct
17 Correct 13 ms 624 KB Output is correct
18 Correct 18 ms 624 KB Output is correct
19 Correct 20 ms 624 KB Output is correct
20 Correct 22 ms 624 KB Output is correct
21 Correct 21 ms 624 KB Output is correct
22 Correct 17 ms 624 KB Output is correct
23 Correct 20 ms 624 KB Output is correct
24 Correct 22 ms 624 KB Output is correct
25 Correct 21 ms 624 KB Output is correct
26 Correct 20 ms 624 KB Output is correct
27 Correct 16 ms 624 KB Output is correct
28 Correct 16 ms 624 KB Output is correct
29 Correct 17 ms 624 KB Output is correct
30 Correct 18 ms 624 KB Output is correct
31 Correct 39 ms 624 KB Output is correct
32 Correct 52 ms 624 KB Output is correct
33 Correct 74 ms 712 KB Output is correct
34 Correct 125 ms 712 KB Output is correct
35 Correct 84 ms 716 KB Output is correct
36 Correct 48 ms 716 KB Output is correct
37 Correct 43 ms 716 KB Output is correct
38 Correct 72 ms 736 KB Output is correct
39 Correct 95 ms 736 KB Output is correct
40 Correct 99 ms 736 KB Output is correct
41 Correct 45 ms 736 KB Output is correct
42 Correct 96 ms 736 KB Output is correct
43 Correct 108 ms 736 KB Output is correct
44 Correct 93 ms 736 KB Output is correct
45 Correct 104 ms 736 KB Output is correct
46 Correct 99 ms 736 KB Output is correct
47 Correct 84 ms 844 KB Output is correct
48 Correct 106 ms 844 KB Output is correct
49 Correct 65 ms 844 KB Output is correct
50 Correct 92 ms 844 KB Output is correct
51 Correct 75 ms 844 KB Output is correct
52 Correct 100 ms 844 KB Output is correct
53 Correct 59 ms 844 KB Output is correct
54 Correct 87 ms 844 KB Output is correct
55 Correct 83 ms 844 KB Output is correct
56 Correct 73 ms 844 KB Output is correct
57 Correct 79 ms 844 KB Output is correct
58 Correct 98 ms 844 KB Output is correct
59 Correct 107 ms 844 KB Output is correct
60 Correct 79 ms 844 KB Output is correct