Submission #639768

# Submission time Handle Problem Language Result Execution time Memory
639768 2022-09-11T15:05:42 Z study Radio Towers (IOI22_towers) C++17
4 / 100
839 ms 1468 KB
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 1e5;
int n, a[MAXN],l[MAXN];
bool ok = true;
int maxi = 0,idx=0;

void init(int N, vector<int> H){
	n = N;
	ok = false;
	maxi = 0;
	for (int i=0; i<n; ++i){
		a[i] = H[i];
		maxi = max(maxi,a[i]);
		if (a[i] == maxi) idx = i;
	}
}
int max_towers(int L, int R, int D){
	if (R < idx or L > idx) return 1;
	if (max(a[L],a[R]) <= maxi-D) return 2;
	return 1;
	int ans = 0;
	if (!ok){
		fill_n(&l[0],MAXN,0);
		ok = true;
		set<int> st;
		st.emplace(INT_MAX);
		st.emplace(INT_MIN);
		vector<pair<int,int>> v;
		for (int i=0; i<n; ++i){
			v.emplace_back(a[i],i);
		}
		sort(v.begin(),v.end());
		int idx = 0;
		for (auto i:v){
			while (idx < n and v[idx].first <= i.first-D){
				st.emplace(v[idx].second);
				idx++;
			}
			auto a = st.upper_bound(i.second), b = a;
			--a;
			if ((*b) != INT_MAX){
				l[*b] = *a;
			}
		}
	}
	vector<int> dp(R+1,1);
	for (int i=L; i<=R; ++i){
		int prev = l[i];
		if (prev >= L){
			dp[i] = dp[prev]+1;
		}
		if (i) dp[i] = max(dp[i],dp[i-1]);
	}
	return dp[R];
}

Compilation message

towers.cpp: In function 'int max_towers(int, int, int)':
towers.cpp:23:6: warning: unused variable 'ans' [-Wunused-variable]
   23 |  int ans = 0;
      |      ^~~
# Verdict Execution time Memory Grader output
1 Correct 392 ms 1024 KB Output is correct
2 Correct 839 ms 1436 KB Output is correct
3 Correct 680 ms 1448 KB Output is correct
4 Correct 686 ms 1468 KB Output is correct
5 Correct 806 ms 1352 KB Output is correct
6 Correct 699 ms 1352 KB Output is correct
7 Correct 766 ms 1448 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '1'
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: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 618 ms 1448 KB 1st lines differ - on the 1st token, expected: '11903', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 230 ms 464 KB 1st lines differ - on the 1st token, expected: '7197', found: '2'
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: '1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 392 ms 1024 KB Output is correct
2 Correct 839 ms 1436 KB Output is correct
3 Correct 680 ms 1448 KB Output is correct
4 Correct 686 ms 1468 KB Output is correct
5 Correct 806 ms 1352 KB Output is correct
6 Correct 699 ms 1352 KB Output is correct
7 Correct 766 ms 1448 KB Output is correct
8 Correct 0 ms 208 KB Output is correct
9 Correct 1 ms 208 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Incorrect 0 ms 208 KB 1st lines differ - on the 1st token, expected: '13', found: '1'
12 Halted 0 ms 0 KB -