답안 #260153

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
260153 2020-08-09T11:51:56 Z sckmd Baloni (COCI15_baloni) C++14
0 / 100
81 ms 131076 KB
#include <bits/stdc++.h>

using namespace std;
#define MAXN 1000005
queue <int> ids[MAXN];

void go(int height,int prev)
{
  if(!ids[height].size())return ;
  int idx = ids[height].front();
  if(idx < prev)return ;
  ids[height].pop();
  go(height-1,idx);
}

int solve()
{
  int ans = 0;
  for(int height = MAXN-1; height > 0;)
  {
    if(!ids[height].size()){height--;continue;}
    go(height,-1);
    ans++;
  }
  return ans;
}

int main()
{
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  for(int i = 1; i <= n; i++)
  {
    int h;
    cin >> h;
    ids[h].push(i);
  }
  cout << solve();
  return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 75 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Runtime error 73 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
3 Runtime error 76 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
4 Runtime error 73 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
5 Runtime error 79 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Runtime error 81 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
7 Runtime error 73 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
8 Runtime error 76 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)
9 Runtime error 76 ms 131072 KB Execution killed with signal 9 (could be triggered by violating memory limits)
10 Runtime error 76 ms 131076 KB Execution killed with signal 9 (could be triggered by violating memory limits)