제출 #774627

#제출 시각아이디문제언어결과실행 시간메모리
774627Magikarp4000송신탑 (IOI22_towers)C++17
11 / 100
4097 ms3700 KiB
#include "towers.h"
#include <bits/stdc++.h>
using namespace std;
#define OPTM ios_base::sync_with_stdio(0); cin.tie(0);
#define INF int(1e9+7)
#define ln '\n' 
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define FOR(i,s,n) for (int i = s; i < n; i++)
#define FORR(i,n,s) for (int i = n; i > s; i--)
#define FORX(u, arr) for (auto u : arr)
#define PB push_back
#define in(v,x) (v.find(x) != v.end())
#define F first
#define S second
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define UM unordered_map
#define US unordered_set
#define PQ priority_queue
#define ALL(v) v.begin(), v.end()
const ll LLINF = 1e18+1;

const int MAXN = 1e5+5;
int n,l,r,d;
int h[MAXN];
US<int> s;

bool check(int start) {
    FORR(i,start-1,-1) {
        if (s.count(i)) return 0;
        if (h[i] >= h[start]+d) return 1;
    }
    return 1;
}

bool check1(int start) {
    FOR(i,start+1,n) {
        if (s.count(i)) return 0;
        if (h[i] >= h[start]+d) return 1;
    }
    return 1;
}

void init(int N, std::vector<int> H) {
    n = N;
    FOR(i,0,n) h[i] = H[i];
}

int max_towers(int L, int R, int D) {
    s.clear();
    l = L, r = R, d = D;
    vector<PII> v;
    FOR(i,l,r+1) v.PB({h[i],i});
    sort(ALL(v));
    int vn = v.size();
    FOR(i,0,vn) {
        int curh = v[i].F, idx = v[i].S;
        if (check(idx) && check1(idx)) s.insert(idx);
    }
    return s.size();
}

컴파일 시 표준 에러 (stderr) 메시지

towers.cpp: In function 'int max_towers(int, int, int)':
towers.cpp:60:13: warning: unused variable 'curh' [-Wunused-variable]
   60 |         int curh = v[i].F, idx = v[i].S;
      |             ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...