답안 #813705

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
813705 2023-08-08T02:20:07 Z LIF 송신탑 (IOI22_towers) C++17
0 / 100
4000 ms 1828 KB
#include "towers.h"
#include <vector>
#include<bits/stdc++.h>
using namespace std;
int n;
pair <int,int> aa[300005];
void init(int N, std::vector<int> H) {
	n = N;
	for(int i=0;i<H.size();i++)
	{
		aa[i+1].first = H[i];
		aa[i+1].second = i;
	}
	sort(aa+1,aa+n+1);
	return;
}
bool choose[300005];
int max_towers(int L, int R, int D)
{
	int ans = 0;
	for(int i=1;i<=n;i++)choose[i] = false;
	for(int i=1;i<=n;i++)
	{
		int xx = aa[i].second;
		int leftmax = -1;
		bool flag = true;
		for(int j=xx-1;j>=1;j--)
		{
			if(choose[j] == false)leftmax = max(leftmax,aa[j].first);
			else
			{
				if(aa[j].first <= leftmax - D && aa[i].first <= leftmax - D)continue;
				else flag = false;
				break;
			}
		}
		int rightmax = -1;
		for(int j=xx+1;j<=n;j++)
		{
			if(choose[j] == false)rightmax = max(rightmax,aa[j].first);
			else
			{
				if(aa[j].first <= rightmax - D && aa[i].first <= rightmax - D)continue;
				else flag = false;
				break;
			}
		}
		if(flag == true)
		{
			ans++;
			choose[xx] = true;
		}
	}
  return ans;
}

Compilation message

towers.cpp: In function 'void init(int, std::vector<int>)':
towers.cpp:9:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |  for(int i=0;i<H.size();i++)
      |              ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4067 ms 1192 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '3'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '3'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4046 ms 1828 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4051 ms 688 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '3'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4067 ms 1192 KB Time limit exceeded
2 Halted 0 ms 0 KB -