답안 #1078842

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1078842 2024-08-28T07:01:22 Z LittleOrange 송신탑 (IOI22_towers) C++17
0 / 100
4000 ms 2236 KB
#include "towers.h"

#include <vector>
#include<bits/stdc++.h>
using namespace std;
using ll = int;
ll n;
vector<ll> h;
ll mx;
struct obj{
  ll v,c;
  bool operator<(const obj &o) const{
    return v<o.v;
  }
  bool operator>(const obj &o) const{
    return v>o.v;
  }
};

void init(int N, std::vector<int> H) {
  n = N;
  h = H;
  for(ll i = 0;i<n;i++) if((i==0||(h[i-1]<h[i]))&&(i==n-1||h[i]>h[i+1])) mx = i;
}

int max_towers(int L, int R, int D) {
  ll l = L, r = R, d = D;
  ll ans = 1;
  vector<obj> a,b;
  a.push_back({0,0});
  for(ll i = l;i<=r;i++){
    ll cur = 0;
    obj oa = {h[i],cur+1};
    while(a.size()&&a.back().v>=h[i]) a.pop_back();
    a.push_back(oa);
  }
  return 1+(L<mx&&mx<R&&max(h[L],h[R])<=h[mx]);
}

Compilation message

towers.cpp: In function 'int max_towers(int, int, int)':
towers.cpp:27:20: warning: unused variable 'd' [-Wunused-variable]
   27 |   ll l = L, r = R, d = D;
      |                    ^
towers.cpp:28:6: warning: unused variable 'ans' [-Wunused-variable]
   28 |   ll ans = 1;
      |      ^~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4006 ms 2236 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4075 ms 1848 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4013 ms 600 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '13', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4006 ms 2236 KB Time limit exceeded
2 Halted 0 ms 0 KB -