답안 #1052555

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1052555 2024-08-10T16:17:47 Z thatsgonzalez Mountains (IOI17_mountains) C++14
0 / 100
1 ms 348 KB
#include "mountains.h"
#include <vector>
#include <bits/stdc++.h>
using namespace std;
 
 
struct ST{
 
	vector<int> st, a;
	int n;
 
	int query(int p, int lq, int rq, int l, int r){
		if(l>r) return 0;
		if(r<lq || l>rq) return 0;
		if(l>=lq and r<=rq) return st[p];
		int mid = (l+r)>>1;
		return max(query(p*2+1,lq,rq,l,mid),query(p*2+2,lq,rq,mid+1,r));
	}
 
	int query(int l, int r){
		return query(0,l,r,0,n-1);
	}
 
	void build(int p, int l, int r){
 
		if(l>r) return;
		if(l == r){
			st[p] = a[l];
		}
 
		int mid = (l+r)>>1;
 
		build(p*2+1,l,mid);
		build(p*2+2,mid+1,r);
 
		st[p] = max(st[p*2+1],st[p*2+2]);
 
	}
 
	void init(vector<int> arr){
		a = arr;
		n = a.size();
		st.assign(4*n+10,0);
		build(0,0,n-1);
	}
 
};

#define sz(x) (int)(x.size())
 
int maximum_deevs(std::vector<int> y) {
	
	int n = y.size();
	int ans = 0;
	//ST st;
	//st.init(y);
	for(int i = 0; i<n; i++){
		vector<int> res; res.push_back(i); 
		for(int j = i+1; j<n; j++){
			bool ok = true; int mx = 0;
			for(int k = j-1, q = sz(res)-1; q>=0; k--){
				if(k == res[q]){
					if(mx<=y[j] || mx<=y[res[q]]){
						ok = false; break;
					}
					else q--;
				}
				mx = max(mx,y[k]);
			}
			if(ok) res.push_back(j);
		}
		ans = max(ans,sz(res));
 
	}
 
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 344 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -