답안 #1078850

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1078850 2024-08-28T07:07:32 Z mickey080929 송신탑 (IOI22_towers) C++17
0 / 100
4000 ms 1492 KB
#include "towers.h"
#include <bits/stdc++.h>

using namespace std;

const int inf = 2e9 + 10;

int N;
vector<int> H;

void init(int _N, vector<int> _H) {
    N = _N;
    H = _H;
}

int max_towers(int L, int R, int D) {
    vector<int> id;
    for (int i=L; i<=R; i++) {
        id.push_back(i);
    }
    sort(id.begin(), id.end(), [&] (int &u, int &v) { return H[u] > H[v]; });
    int ans = 1;
    for (int i=1; i<=id.size(); i++) {
        vector<int> pos = {L-1, R+1};
        for (int j=0; j<i; j++) {
            pos.push_back(id[j]);
        }
        sort(pos.begin(), pos.end());
        int cnt = 0;
        for (int j=0; j+1<pos.size(); j++) {
            int lh, rh;
            if (pos[j] == L-1) lh = inf;
            else lh = H[pos[j]];
            if (pos[j+1] == R+1) rh = inf;
            else rh = H[pos[j+1]];
            for (int k=pos[j]+1; k<=pos[j+1]-1; k++) {
                if (H[k] <= min(lh, rh) - D) {
                    cnt ++;
                    break;
                }
            }
        }
        ans = max(ans, cnt);
    }
    return ans;

    return 0;
}

Compilation message

towers.cpp: In function 'int max_towers(int, int, int)':
towers.cpp:23:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for (int i=1; i<=id.size(); i++) {
      |                   ~^~~~~~~~~~~
towers.cpp:30:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         for (int j=0; j+1<pos.size(); j++) {
      |                       ~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4065 ms 1112 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '11'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '11'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4042 ms 1492 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4016 ms 856 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '11'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4065 ms 1112 KB Time limit exceeded
2 Halted 0 ms 0 KB -