답안 #1081892

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1081892 2024-08-30T12:36:31 Z farica 송신탑 (IOI22_towers) C++17
0 / 100
455 ms 1748 KB
#include "towers.h"

#include <bits/stdc++.h>

using namespace std;

int n,sub1=1,idx=0;
vector<int> h;

void init(int N, vector<int> H) {
    n = N;
    for(auto x : H)
        h.push_back(x);
    int ok=1;
    for(int i=0; i<H.size()-1; i++) {
        if(ok and H[i] > H[i+1]) {
            ok=0;
            idx = i;
        }
        if(!ok and H[i] < H[i+1])
            sub1=0;
    }
}

int max_towers(int L, int R, int D) {
    if(sub1) {
        if(idx > L and idx < R and (h[L]+D) <= h[idx] and (h[R]+D) <= h[idx])
            return 2;
        else
            return 0;
    }
}

Compilation message

towers.cpp: In function 'void init(int, std::vector<int>)':
towers.cpp:15:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for(int i=0; i<H.size()-1; i++) {
      |                  ~^~~~~~~~~~~
towers.cpp: In function 'int max_towers(int, int, int)':
towers.cpp:32:1: warning: control reaches end of non-void function [-Wreturn-type]
   32 | }
      | ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 273 ms 1236 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 455 ms 1748 KB 1st lines differ - on the 1st token, expected: '11903', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 196 ms 600 KB 1st lines differ - on the 1st token, expected: '7197', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 273 ms 1236 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -