답안 #650879

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
650879 2022-10-15T23:04:26 Z NaimSS 송신탑 (IOI22_towers) C++17
0 / 100
447 ms 2096 KB
#include "towers.h"
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
#include <vector>

const int N = 100100;
int cnt[N];
int h[N];
vector<int> pos;
void init(int N, std::vector<int> H) {
  cnt[0] = (N > 1 && H[0] < H[1]);
  if(cnt[0])pos.pb(0);
  for(int i=0;i<N;i++)h[i] = H[i];
  for(int i=1;i<N;i++){
    cnt[i]=cnt[i-1];
    if(H[i] < H[i-1]){
      cnt[i]++;
      pos.pb(i);
    }
  }
}

int max_towers(int L, int R, int D) {
  int v = (L+1<=R && h[L] < h[L+1]);
  int p = upper_bound(pos.begin(),pos.end(),L) - pos.begin();

  if(p == pos.size() || pos[p] > R)return 1;
  int qtd = cnt[R] - cnt[pos[p]-1];
  if(v)qtd++;
  return qtd;
}

Compilation message

towers.cpp: In function 'int max_towers(int, int, int)':
towers.cpp:28:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |   if(p == pos.size() || pos[p] > R)return 1;
      |      ~~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 447 ms 1360 KB 2nd lines differ - on the 1st token, expected: '1', found: '8351'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '25'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '25'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 331 ms 2096 KB 1st lines differ - on the 1st token, expected: '11903', found: '18072'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 265 ms 840 KB 1st lines differ - on the 1st token, expected: '7197', found: '11951'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '25'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 447 ms 1360 KB 2nd lines differ - on the 1st token, expected: '1', found: '8351'
2 Halted 0 ms 0 KB -