Submission #1067502

# Submission time Handle Problem Language Result Execution time Memory
1067502 2024-08-20T18:40:12 Z mariaclara Radio Towers (IOI22_towers) C++17
14 / 100
652 ms 2900 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++;
    
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 256 ms 1624 KB 18th lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '16'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '16'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 474 ms 2616 KB Output is correct
2 Correct 572 ms 2648 KB Output is correct
3 Correct 605 ms 2648 KB Output is correct
4 Correct 652 ms 2648 KB Output is correct
5 Correct 607 ms 2648 KB Output is correct
6 Correct 610 ms 2648 KB Output is correct
7 Correct 582 ms 2900 KB Output is correct
8 Correct 578 ms 2648 KB Output is correct
9 Correct 571 ms 2648 KB Output is correct
10 Correct 565 ms 2648 KB Output is correct
11 Correct 602 ms 2648 KB Output is correct
12 Correct 576 ms 2648 KB Output is correct
13 Correct 583 ms 2900 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 17 ms 2772 KB Output is correct
19 Correct 9 ms 2648 KB Output is correct
20 Correct 9 ms 2696 KB Output is correct
21 Correct 9 ms 2648 KB Output is correct
22 Correct 18 ms 2620 KB Output is correct
23 Correct 9 ms 2648 KB Output is correct
24 Correct 17 ms 2628 KB Output is correct
25 Correct 9 ms 2620 KB Output is correct
26 Correct 10 ms 2608 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 0 ms 344 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 0 ms 344 KB Output is correct
31 Correct 0 ms 344 KB Output is correct
32 Correct 1 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
# Verdict Execution time Memory Grader output
1 Incorrect 176 ms 976 KB 1st lines differ - on the 1st token, expected: '7197', found: '8004'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '16'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 256 ms 1624 KB 18th lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -