답안 #469814

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
469814 2021-09-01T19:33:58 Z ljuba Xylophone (JOI18_xylophone) C++17
100 / 100
134 ms 432 KB
#include "xylophone.h"
#include <bits/stdc++.h>

using namespace std;

void solve(int N) {
    vector<int> v(N+1), v2(N+1);

    for(int i = 1; i + 1 <= N; ++i) {
        v[i] = query(i, i+1);
    }

    for(int i = 1; i + 2 <= N; ++i) {
        v2[i] = query(i, i+2);
    }

    vector<int> znak(N+1, 1);
    vector<int> konacno(N+1);
    konacno[2] = v[1];

    //znak[2] je 1

    for(int i = 3; i <= N; ++i) {
        znak[i] = znak[i-1];
        if(v[i-2] + v[i-1] != v2[i-2]) {
            znak[i] = znak[i-1] * (-1);
        }
        konacno[i] = konacno[i-1] + znak[i] * v[i-1];
    }

    int mini = 1, maksi = 1;

    for(int i = 2; i <= N; ++i) {
        if(konacno[i] < konacno[mini]) {
            mini = i;
        }
        if(konacno[i] > konacno[maksi]) {
            maksi = i;
        }
    }

    if(mini > maksi) {
        for(int i = 2; i <= N; ++i) {
            znak[i] *= (-1);
            konacno[i] = konacno[i-1] + znak[i] * v[i-1];
        }

        mini = 1;
        for(int i = 2; i <= N; ++i) {
            if(konacno[i] < konacno[mini]) {
                mini = i;
            }
        }
    }

    vector<int> ans(N+1);

    for(int i = 1; i <= N; ++i) {
        ans[i] = (konacno[i] - konacno[mini] + 1);
    }

    for(int i = 1; i <= N; ++i) {
        answer(i, ans[i]);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 4 ms 200 KB Output is correct
5 Correct 3 ms 200 KB Output is correct
6 Correct 3 ms 200 KB Output is correct
7 Correct 3 ms 200 KB Output is correct
8 Correct 2 ms 200 KB Output is correct
9 Correct 3 ms 200 KB Output is correct
10 Correct 2 ms 200 KB Output is correct
11 Correct 3 ms 200 KB Output is correct
12 Correct 3 ms 200 KB Output is correct
13 Correct 2 ms 200 KB Output is correct
14 Correct 3 ms 200 KB Output is correct
15 Correct 3 ms 200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 4 ms 200 KB Output is correct
5 Correct 3 ms 200 KB Output is correct
6 Correct 3 ms 200 KB Output is correct
7 Correct 3 ms 200 KB Output is correct
8 Correct 2 ms 200 KB Output is correct
9 Correct 3 ms 200 KB Output is correct
10 Correct 2 ms 200 KB Output is correct
11 Correct 3 ms 200 KB Output is correct
12 Correct 3 ms 200 KB Output is correct
13 Correct 2 ms 200 KB Output is correct
14 Correct 3 ms 200 KB Output is correct
15 Correct 3 ms 200 KB Output is correct
16 Correct 5 ms 200 KB Output is correct
17 Correct 9 ms 200 KB Output is correct
18 Correct 18 ms 200 KB Output is correct
19 Correct 24 ms 284 KB Output is correct
20 Correct 24 ms 292 KB Output is correct
21 Correct 19 ms 292 KB Output is correct
22 Correct 17 ms 292 KB Output is correct
23 Correct 9 ms 292 KB Output is correct
24 Correct 18 ms 280 KB Output is correct
25 Correct 19 ms 284 KB Output is correct
26 Correct 21 ms 284 KB Output is correct
27 Correct 18 ms 292 KB Output is correct
28 Correct 19 ms 280 KB Output is correct
29 Correct 9 ms 296 KB Output is correct
30 Correct 23 ms 284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 200 KB Output is correct
2 Correct 0 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 4 ms 200 KB Output is correct
5 Correct 3 ms 200 KB Output is correct
6 Correct 3 ms 200 KB Output is correct
7 Correct 3 ms 200 KB Output is correct
8 Correct 2 ms 200 KB Output is correct
9 Correct 3 ms 200 KB Output is correct
10 Correct 2 ms 200 KB Output is correct
11 Correct 3 ms 200 KB Output is correct
12 Correct 3 ms 200 KB Output is correct
13 Correct 2 ms 200 KB Output is correct
14 Correct 3 ms 200 KB Output is correct
15 Correct 3 ms 200 KB Output is correct
16 Correct 5 ms 200 KB Output is correct
17 Correct 9 ms 200 KB Output is correct
18 Correct 18 ms 200 KB Output is correct
19 Correct 24 ms 284 KB Output is correct
20 Correct 24 ms 292 KB Output is correct
21 Correct 19 ms 292 KB Output is correct
22 Correct 17 ms 292 KB Output is correct
23 Correct 9 ms 292 KB Output is correct
24 Correct 18 ms 280 KB Output is correct
25 Correct 19 ms 284 KB Output is correct
26 Correct 21 ms 284 KB Output is correct
27 Correct 18 ms 292 KB Output is correct
28 Correct 19 ms 280 KB Output is correct
29 Correct 9 ms 296 KB Output is correct
30 Correct 23 ms 284 KB Output is correct
31 Correct 36 ms 300 KB Output is correct
32 Correct 52 ms 292 KB Output is correct
33 Correct 70 ms 328 KB Output is correct
34 Correct 68 ms 312 KB Output is correct
35 Correct 95 ms 320 KB Output is correct
36 Correct 131 ms 312 KB Output is correct
37 Correct 83 ms 328 KB Output is correct
38 Correct 120 ms 320 KB Output is correct
39 Correct 109 ms 328 KB Output is correct
40 Correct 109 ms 328 KB Output is correct
41 Correct 79 ms 432 KB Output is correct
42 Correct 91 ms 308 KB Output is correct
43 Correct 97 ms 328 KB Output is correct
44 Correct 86 ms 320 KB Output is correct
45 Correct 114 ms 360 KB Output is correct
46 Correct 117 ms 328 KB Output is correct
47 Correct 134 ms 320 KB Output is correct
48 Correct 110 ms 328 KB Output is correct
49 Correct 110 ms 320 KB Output is correct
50 Correct 93 ms 328 KB Output is correct
51 Correct 124 ms 320 KB Output is correct
52 Correct 122 ms 328 KB Output is correct
53 Correct 116 ms 328 KB Output is correct
54 Correct 118 ms 328 KB Output is correct
55 Correct 97 ms 328 KB Output is correct
56 Correct 90 ms 328 KB Output is correct
57 Correct 89 ms 328 KB Output is correct
58 Correct 125 ms 332 KB Output is correct
59 Correct 115 ms 328 KB Output is correct
60 Correct 123 ms 308 KB Output is correct