Submission #739810

# Submission time Handle Problem Language Result Execution time Memory
739810 2023-05-11T10:47:39 Z Nonoze Radio Towers (IOI22_towers) C++17
0 / 100
693 ms 5664 KB
#include "towers.h"

#include <bits/stdc++.h>
using namespace std;

int kval, k, n, premier, dernier;
set<pair<int, int>> avant;
set<pair<int, int>> apres;

void init(int tempn, vector<int> temph) {
	n=tempn;
	premier=temph[0], dernier=temph[n-1];
	for (int i = 1; i < n; ++i)
	{
		if (temph[i]<temph[i-1])
		{
			kval=temph[i-1], k=i-1;
			break;
		}
		avant.insert({temph[i-1], i-1});
	}
	for (int i = k+1; i < n; ++i)
	{
		apres.insert({temph[i], i});
	}
	return;
}

int max_towers(int L, int R, int D) {
	if (kval-D<premier || kval-D<dernier || R-L<3) return 0;
	auto itl=avant.lower_bound({kval-D, 0});
	auto itr=apres.lower_bound({kval-D, 0});
	if (itl==avant.end() || itr==apres.end()) itl--, itr--;
	auto a=*itl, b=*itr;
	int l=a.second, r=b.second;
	if (l<L || r>R) return 0;
	return (l-L+1)*(R-r+1);
}
# Verdict Execution time Memory Grader output
1 Incorrect 391 ms 3548 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 693 ms 5664 KB 1st lines differ - on the 1st token, expected: '11903', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 262 ms 1488 KB 1st lines differ - on the 1st token, expected: '7197', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 391 ms 3548 KB 1st lines differ - on the 1st token, expected: '1', found: '0'
2 Halted 0 ms 0 KB -