답안 #17293

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
17293 2015-11-14T17:27:43 Z gs14004 걷기 (NOI12_walking) C++14
25 / 25
0 ms 1728 KB
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <functional>
#include <vector>
#include <numeric>
#include <deque>
#include <utility>
#include <bitset>
#include <iostream>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;

int dp[505], l, n;
pi a[505];

bool ok(int p, int q){
	return (a[p].first < a[q].first) && 
	(l * a[q].second + a[p].first * a[p].second * a[q].second > l * a[p].second + a[q].first * a[p].second * a[q].second);
}

int main(){
	scanf("%d %d",&l,&n);
	for(int i=0; i<n; i++){
		scanf("%d %d",&a[i].first, &a[i].second);
	}
	sort(a, a+n);
	for(int i=n-1; i>=0; i--){
		dp[i] = 1;
		for(int j=i+1; j<n; j++){
			if(ok(i,j)) dp[i] = max(dp[i], dp[j] + 1);
		}
	}
	printf("%d",*max_element(dp, dp+n));
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1728 KB Output is correct
2 Correct 0 ms 1728 KB Output is correct
3 Correct 0 ms 1728 KB Output is correct
4 Correct 0 ms 1728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1728 KB Output is correct
2 Correct 0 ms 1728 KB Output is correct
3 Correct 0 ms 1728 KB Output is correct
4 Correct 0 ms 1728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1728 KB Output is correct
2 Correct 0 ms 1728 KB Output is correct
3 Correct 0 ms 1728 KB Output is correct
4 Correct 0 ms 1728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1728 KB Output is correct
2 Correct 0 ms 1728 KB Output is correct
3 Correct 0 ms 1728 KB Output is correct
4 Correct 0 ms 1728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 1728 KB Output is correct
2 Correct 0 ms 1728 KB Output is correct
3 Correct 0 ms 1728 KB Output is correct
4 Correct 0 ms 1728 KB Output is correct