답안 #968726

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
968726 2024-04-24T00:23:16 Z maksim1744 송신탑 (IOI22_towers) C++17
23 / 100
4000 ms 1856 KB
/*
    author:  Maksim1744
    created: 24.04.2024 03:13:57
*/

#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;

#define mp   make_pair
#define pb   push_back
#define eb   emplace_back

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

template<typename T>             vector<T>& operator--            (vector<T> &v){for (auto& i : v) --i;            return  v;}
template<typename T>             vector<T>& operator++            (vector<T> &v){for (auto& i : v) ++i;            return  v;}
template<typename T>             istream& operator>>(istream& is,  vector<T> &v){for (auto& i : v) is >> i;        return is;}
template<typename T>             ostream& operator<<(ostream& os,  vector<T>  v){for (auto& i : v) os << i << ' '; return os;}
template<typename T, typename U> pair<T,U>& operator--           (pair<T, U> &p){--p.first; --p.second;            return  p;}
template<typename T, typename U> pair<T,U>& operator++           (pair<T, U> &p){++p.first; ++p.second;            return  p;}
template<typename T, typename U> istream& operator>>(istream& is, pair<T, U> &p){is >> p.first >> p.second;        return is;}
template<typename T, typename U> ostream& operator<<(ostream& os, pair<T, U>  p){os << p.first << ' ' << p.second; return os;}
template<typename T, typename U> pair<T,U> operator-(pair<T,U> a, pair<T,U> b){return mp(a.first-b.first, a.second-b.second);}
template<typename T, typename U> pair<T,U> operator+(pair<T,U> a, pair<T,U> b){return mp(a.first+b.first, a.second+b.second);}
template<typename T, typename U> void umin(T& a, U b){if (a > b) a = b;}
template<typename T, typename U> void umax(T& a, U b){if (a < b) a = b;}

#ifdef HOME
#define SHOW_COLORS
#include "/mnt/c/Libs/tools/print.cpp"
#else
#define show(...) void(0)
#define debugf(fun)   fun
#define debugv(var)   var
#define mclock    void(0)
#define shows     void(0)
#define debug  if (false)
#define OSTREAM(...)    ;
#define OSTREAM0(...)   ;
#endif

int n;
vector<int> h;

void init(int n, std::vector<int> h) {
    ::n = n;
    ::h = h;
}

int max_towers(int l, int r, int d) {
    int dir = -1;
    int last = h[l];
    int ans = 0;
    for (int i = l + 1; i <= r; ++i) {
        if (dir == -1) {
            if (h[i] >= last + d) {
                dir = -dir;
                last = h[i];
                ++ans;
            } else {
                last = min(last, h[i]);
            }
        } else {
            if (h[i] <= last - d) {
                dir = -dir;
                last = h[i];
                ++ans;
            } else {
                last = max(last, h[i]);
            }
        }
    }
    return ans / 2 + 1;
}


#ifdef HOUSE
int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    int n, q;
    cin >> n >> q;
    vector<int> h(n);
    cin >> h;
    init(n, h);
    while (q--) {
        int l, r, d;
        cin >> l >> r >> d;
        cout << max_towers(l, r, d) << '\n';
    }

    return 0;
}
#endif
# 결과 실행 시간 메모리 Grader output
1 Correct 1221 ms 1112 KB Output is correct
2 Execution timed out 4054 ms 1596 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 432 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 1 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 1 ms 344 KB Output is correct
32 Correct 0 ms 440 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 432 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 1 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 1 ms 344 KB Output is correct
32 Correct 0 ms 440 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 8 ms 1112 KB Output is correct
37 Correct 9 ms 1368 KB Output is correct
38 Correct 9 ms 1596 KB Output is correct
39 Correct 9 ms 1600 KB Output is correct
40 Correct 9 ms 1604 KB Output is correct
41 Correct 9 ms 1384 KB Output is correct
42 Correct 9 ms 1608 KB Output is correct
43 Correct 9 ms 1604 KB Output is correct
44 Correct 9 ms 1600 KB Output is correct
45 Correct 9 ms 1368 KB Output is correct
46 Correct 14 ms 1600 KB Output is correct
47 Correct 9 ms 1600 KB Output is correct
48 Correct 9 ms 1368 KB Output is correct
49 Correct 9 ms 1848 KB Output is correct
50 Correct 9 ms 1596 KB Output is correct
51 Correct 14 ms 1600 KB Output is correct
52 Correct 10 ms 1600 KB Output is correct
53 Correct 10 ms 1600 KB Output is correct
54 Correct 9 ms 1600 KB Output is correct
55 Correct 9 ms 1588 KB Output is correct
56 Correct 15 ms 1604 KB Output is correct
57 Correct 15 ms 1332 KB Output is correct
58 Correct 9 ms 1600 KB Output is correct
59 Correct 10 ms 1604 KB Output is correct
60 Correct 9 ms 1612 KB Output is correct
61 Correct 9 ms 1604 KB Output is correct
62 Correct 9 ms 1600 KB Output is correct
63 Correct 9 ms 1596 KB Output is correct
64 Correct 9 ms 1604 KB Output is correct
65 Correct 9 ms 1600 KB Output is correct
66 Correct 9 ms 1804 KB Output is correct
67 Correct 9 ms 1856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4081 ms 1596 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2820 ms 708 KB Output is correct
2 Execution timed out 4086 ms 1600 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 344 KB Output is correct
13 Correct 1 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 344 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 1 ms 432 KB Output is correct
18 Correct 1 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 0 ms 344 KB Output is correct
22 Correct 0 ms 344 KB Output is correct
23 Correct 1 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 0 ms 344 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 0 ms 344 KB Output is correct
28 Correct 1 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 1 ms 344 KB Output is correct
32 Correct 0 ms 440 KB Output is correct
33 Correct 1 ms 344 KB Output is correct
34 Correct 1 ms 344 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 8 ms 1112 KB Output is correct
37 Correct 9 ms 1368 KB Output is correct
38 Correct 9 ms 1596 KB Output is correct
39 Correct 9 ms 1600 KB Output is correct
40 Correct 9 ms 1604 KB Output is correct
41 Correct 9 ms 1384 KB Output is correct
42 Correct 9 ms 1608 KB Output is correct
43 Correct 9 ms 1604 KB Output is correct
44 Correct 9 ms 1600 KB Output is correct
45 Correct 9 ms 1368 KB Output is correct
46 Correct 14 ms 1600 KB Output is correct
47 Correct 9 ms 1600 KB Output is correct
48 Correct 9 ms 1368 KB Output is correct
49 Correct 9 ms 1848 KB Output is correct
50 Correct 9 ms 1596 KB Output is correct
51 Correct 14 ms 1600 KB Output is correct
52 Correct 10 ms 1600 KB Output is correct
53 Correct 10 ms 1600 KB Output is correct
54 Correct 9 ms 1600 KB Output is correct
55 Correct 9 ms 1588 KB Output is correct
56 Correct 15 ms 1604 KB Output is correct
57 Correct 15 ms 1332 KB Output is correct
58 Correct 9 ms 1600 KB Output is correct
59 Correct 10 ms 1604 KB Output is correct
60 Correct 9 ms 1612 KB Output is correct
61 Correct 9 ms 1604 KB Output is correct
62 Correct 9 ms 1600 KB Output is correct
63 Correct 9 ms 1596 KB Output is correct
64 Correct 9 ms 1604 KB Output is correct
65 Correct 9 ms 1600 KB Output is correct
66 Correct 9 ms 1804 KB Output is correct
67 Correct 9 ms 1856 KB Output is correct
68 Execution timed out 4081 ms 1596 KB Time limit exceeded
69 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1221 ms 1112 KB Output is correct
2 Execution timed out 4054 ms 1596 KB Time limit exceeded
3 Halted 0 ms 0 KB -