답안 #306228

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
306228 2020-09-24T23:29:03 Z CaroLinda Mountains (IOI17_mountains) C++14
0 / 100
1 ms 384 KB
#include "mountains.h"
#include <bits/stdc++.h>

#define sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define ll long long

using namespace std ;

struct Fraq
{
	ll num , den ;
	Fraq(ll num = 0 , ll den = 1 ) : num(num), den(den) {}
	bool operator < (Fraq other) const { return num * other.den < den * other.num ; }
	bool operator == (Fraq other) const { return num * other.den == den * other.num ; }
	bool operator > (Fraq other) const { return num * other.den > den * other.num ; }
} ;

int maximum_deevs(std::vector<int> y) {

	int n = sz(y) ;
	vector<int> dp(n,1) ;

	for(int i = n-1 ; i >= 0 ; i-- )
	{
		set<Fraq> s ;

		for(int j = i + 1 ; j < n ; j++ )
		{

			Fraq slope = Fraq( y[j] - y[i] , j - i ) ;
			
			if(s.upper_bound(slope) != s.end() ) dp[i] = max(dp[i] , dp[j] + 1 ) ;

			s.insert(Fraq(y[j], j) ) ;

		}

	}

	return *max_element(all(dp) ) ;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Incorrect 1 ms 256 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Incorrect 1 ms 256 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Incorrect 1 ms 256 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Incorrect 1 ms 256 KB Output isn't correct
8 Halted 0 ms 0 KB -