답안 #1067503

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1067503 2024-08-20T18:41:55 Z mariaclara 송신탑 (IOI22_towers) C++17
18 / 100
658 ms 2792 KB
#include "towers.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mk make_pair
#define pb push_back
#define fr first
#define sc second

vector<int> val_l, val_r, h, pref;

void init(int N, vector<int> H) {
    val_l.resize(N);
    val_r.resize(N);
    pref.resize(N);
    h = H;

    for(int i = 0; i < N; i++) {
        if(i == 0 or H[i-1] < H[i]) val_l[i] = H[i];
        else val_l[i] = val_l[i-1];
    }

    for(int i = N-1; i >= 0; i--) {
        if(i == N-1 or H[i+1] < H[i]) val_r[i] = H[i];
        else val_r[i] = val_r[i+1];
    }

    for(int i = 1; i < N-1; i++) {
        if(H[i-1] > H[i] and H[i] < H[i+1]) pref[i] = pref[i-1] + 1;
        else pref[i] = pref[i-1];
    }
}

int max_towers(int L, int R, int D) {
    int ans = 0;

    // for(int i = L, last = -1, m = 0; i <= R; i++) {
    //     if(last == -1 or min(m - h[last], m - h[i]) >= D) last = i, ans++, m = 0;
    //     if(h[i] < h[last]) last = i, m = 0;
    //     m = max(m, h[i]);
    // }

    if(val_l[L] == val_l[R] or val_r[L] == val_r[R]) return 1;
    ans = pref[R-1] - pref[L];

    if(val_r[L] - h[L] >= D) ans++;
    if(val_l[R] - h[R] >= D) ans++;

    ans = max(ans, 1);
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 278 ms 1620 KB Output is correct
2 Correct 502 ms 2648 KB Output is correct
3 Correct 658 ms 2648 KB Output is correct
4 Correct 607 ms 2648 KB Output is correct
5 Correct 603 ms 2648 KB Output is correct
6 Correct 624 ms 2648 KB Output is correct
7 Correct 623 ms 2624 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '16'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '16'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 436 ms 2648 KB Output is correct
2 Correct 620 ms 2648 KB Output is correct
3 Correct 560 ms 2648 KB Output is correct
4 Correct 593 ms 2648 KB Output is correct
5 Correct 627 ms 2648 KB Output is correct
6 Correct 621 ms 2620 KB Output is correct
7 Correct 588 ms 2648 KB Output is correct
8 Correct 567 ms 2648 KB Output is correct
9 Correct 578 ms 2648 KB Output is correct
10 Correct 576 ms 2648 KB Output is correct
11 Correct 583 ms 2648 KB Output is correct
12 Correct 632 ms 2648 KB Output is correct
13 Correct 604 ms 2648 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 10 ms 2648 KB Output is correct
18 Correct 9 ms 2648 KB Output is correct
19 Correct 9 ms 2732 KB Output is correct
20 Correct 9 ms 2648 KB Output is correct
21 Correct 9 ms 2648 KB Output is correct
22 Correct 17 ms 2792 KB Output is correct
23 Correct 9 ms 2648 KB Output is correct
24 Correct 9 ms 2648 KB Output is correct
25 Correct 9 ms 2648 KB Output is correct
26 Correct 9 ms 2732 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 344 KB Output is correct
29 Correct 0 ms 344 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 1 ms 344 KB Output is correct
32 Correct 0 ms 344 KB Output is correct
33 Correct 0 ms 344 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 0 ms 344 KB Output is correct
36 Correct 0 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 195 ms 972 KB 1st lines differ - on the 1st token, expected: '7197', found: '8004'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '16'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 278 ms 1620 KB Output is correct
2 Correct 502 ms 2648 KB Output is correct
3 Correct 658 ms 2648 KB Output is correct
4 Correct 607 ms 2648 KB Output is correct
5 Correct 603 ms 2648 KB Output is correct
6 Correct 624 ms 2648 KB Output is correct
7 Correct 623 ms 2624 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '16'
12 Halted 0 ms 0 KB -