답안 #626369

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
626369 2022-08-11T12:10:07 Z whynotshadow 송신탑 (IOI22_towers) C++17
15 / 100
4000 ms 2856 KB
#include "towers.h"
#include <bits/stdc++.h>
//#include <cassert>
//#include <cstdio>
#define ll int
//#include <vector>
using namespace std;
vector<ll>v;
const ll N=1e5+9;
const ll INF=1e9;
ll tr[4*N],sz,szz,k,fll;
void build(ll x, ll l_x, ll r_x){
    if(l_x==r_x) tr[x]=v[l_x-1];
    else{
        ll mid=(l_x+r_x)>>1;
        build(x<<1,l_x,mid);
        build(x<<1|1,mid+1,r_x);
        tr[x]=max(tr[x<<1],tr[x<<1|1]);
    }
}
ll GET(ll x, ll l_x, ll r_x, ll l, ll r){
    if(l_x>r || l>r_x) return -INF;
    if(l<=l_x && r_x<=r) return tr[x];
    ll mid=(l_x+r_x)>>1;
    return max(GET(x<<1,l_x,mid,l,r),GET(x<<1|1,mid+1,r_x,l,r));
}
void init(int N, std::vector<int> H) {
    for(auto to:H){
        v.push_back(to);
    }
    k=0,fll=0;
    for(int i=1; i<N; i++){
        if(v[i]>v[i-1]) szz=i;
        else fll=1;
        if(fll==1 && v[i-1]<=v[i]) k=1;
    }
    if(k==1){
        sz=1ll;
        while(sz<N) sz<<=1;
        build(1ll,1ll,sz);
    }
}

int max_towers(int L, int R, int D) {
    if(k==0){
        if(L<=szz && szz<=R && v[L]<=v[szz]-D && v[R]<=v[szz]-D) return 2;
        return 1;
    }
    vector<pair<ll,ll>>cur,anss;
    for(int i=L; i<=R; i++){
        cur.push_back(make_pair(v[i],i));
    }
    sort(cur.begin(),cur.end());
    for(auto [to,it]:cur){
        bool fl=0;
        for(auto [to2,it2]:anss){
            ll res=GET(1,1,sz,min(it,it2)+2,max(it,it2))-D;
            if(res>=to && res>=to2 && abs(it-it2)!=1) fl=0;
            else{
                fl=1;
                break;
            }
        }
        if(fl==0) anss.push_back(make_pair(to,it));
    }
    return anss.size();
//    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 224 ms 1048 KB Output is correct
2 Correct 867 ms 1696 KB Output is correct
3 Correct 706 ms 1696 KB Output is correct
4 Correct 746 ms 1724 KB Output is correct
5 Correct 739 ms 1704 KB Output is correct
6 Correct 682 ms 1740 KB Output is correct
7 Correct 845 ms 1704 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 288 KB Output is correct
2 Correct 15 ms 372 KB Output is correct
3 Correct 2 ms 336 KB Output is correct
4 Correct 12 ms 336 KB Output is correct
5 Correct 4 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 66 ms 352 KB Output is correct
17 Correct 8 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 78 ms 352 KB Output is correct
21 Correct 114 ms 352 KB Output is correct
22 Correct 110 ms 348 KB Output is correct
23 Correct 1 ms 208 KB Output is correct
24 Correct 1 ms 308 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 5 ms 368 KB Output is correct
27 Correct 30 ms 336 KB Output is correct
28 Correct 24 ms 456 KB Output is correct
29 Correct 28 ms 336 KB Output is correct
30 Correct 8 ms 372 KB Output is correct
31 Correct 11 ms 336 KB Output is correct
32 Correct 1 ms 208 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 2 ms 336 KB Output is correct
35 Correct 2 ms 336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 288 KB Output is correct
2 Correct 15 ms 372 KB Output is correct
3 Correct 2 ms 336 KB Output is correct
4 Correct 12 ms 336 KB Output is correct
5 Correct 4 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 66 ms 352 KB Output is correct
17 Correct 8 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 78 ms 352 KB Output is correct
21 Correct 114 ms 352 KB Output is correct
22 Correct 110 ms 348 KB Output is correct
23 Correct 1 ms 208 KB Output is correct
24 Correct 1 ms 308 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 5 ms 368 KB Output is correct
27 Correct 30 ms 336 KB Output is correct
28 Correct 24 ms 456 KB Output is correct
29 Correct 28 ms 336 KB Output is correct
30 Correct 8 ms 372 KB Output is correct
31 Correct 11 ms 336 KB Output is correct
32 Correct 1 ms 208 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 2 ms 336 KB Output is correct
35 Correct 2 ms 336 KB Output is correct
36 Execution timed out 4022 ms 1736 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4098 ms 2856 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4042 ms 1232 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 288 KB Output is correct
2 Correct 15 ms 372 KB Output is correct
3 Correct 2 ms 336 KB Output is correct
4 Correct 12 ms 336 KB Output is correct
5 Correct 4 ms 336 KB Output is correct
6 Correct 2 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 0 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 208 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 66 ms 352 KB Output is correct
17 Correct 8 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 78 ms 352 KB Output is correct
21 Correct 114 ms 352 KB Output is correct
22 Correct 110 ms 348 KB Output is correct
23 Correct 1 ms 208 KB Output is correct
24 Correct 1 ms 308 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 5 ms 368 KB Output is correct
27 Correct 30 ms 336 KB Output is correct
28 Correct 24 ms 456 KB Output is correct
29 Correct 28 ms 336 KB Output is correct
30 Correct 8 ms 372 KB Output is correct
31 Correct 11 ms 336 KB Output is correct
32 Correct 1 ms 208 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 2 ms 336 KB Output is correct
35 Correct 2 ms 336 KB Output is correct
36 Execution timed out 4022 ms 1736 KB Time limit exceeded
37 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 224 ms 1048 KB Output is correct
2 Correct 867 ms 1696 KB Output is correct
3 Correct 706 ms 1696 KB Output is correct
4 Correct 746 ms 1724 KB Output is correct
5 Correct 739 ms 1704 KB Output is correct
6 Correct 682 ms 1740 KB Output is correct
7 Correct 845 ms 1704 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 0 ms 288 KB Output is correct
12 Correct 15 ms 372 KB Output is correct
13 Correct 2 ms 336 KB Output is correct
14 Correct 12 ms 336 KB Output is correct
15 Correct 4 ms 336 KB Output is correct
16 Correct 2 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 208 KB Output is correct
19 Correct 1 ms 208 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 0 ms 208 KB Output is correct
23 Correct 1 ms 208 KB Output is correct
24 Correct 1 ms 208 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 66 ms 352 KB Output is correct
27 Correct 8 ms 336 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 78 ms 352 KB Output is correct
31 Correct 114 ms 352 KB Output is correct
32 Correct 110 ms 348 KB Output is correct
33 Correct 1 ms 208 KB Output is correct
34 Correct 1 ms 308 KB Output is correct
35 Correct 1 ms 336 KB Output is correct
36 Correct 5 ms 368 KB Output is correct
37 Correct 30 ms 336 KB Output is correct
38 Correct 24 ms 456 KB Output is correct
39 Correct 28 ms 336 KB Output is correct
40 Correct 8 ms 372 KB Output is correct
41 Correct 11 ms 336 KB Output is correct
42 Correct 1 ms 208 KB Output is correct
43 Correct 1 ms 208 KB Output is correct
44 Correct 2 ms 336 KB Output is correct
45 Correct 2 ms 336 KB Output is correct
46 Execution timed out 4022 ms 1736 KB Time limit exceeded
47 Halted 0 ms 0 KB -