답안 #676466

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
676466 2022-12-31T03:31:32 Z penguin133 걷기 (NOI12_walking) C++17
25 / 25
42 ms 1236 KB
#include <bits/stdc++.h>
using namespace std;
int grid[505][505];
int dp[505], maxi=1;
pair<int, int>a[505];
int main(){
	int l,n;
	cin >> l >> n;
	for(int i=0;i<n;i++)cin >> a[i].first >> a[i].second;
	sort(a, a +  n);
	for(int i=0;i<n;i++){
		grid[i][i] = 1;
		for(int j=0;j<n;j++){
			double x = double(l)/double(a[i].second) + a[i].first;
			double y = double(l)/double(a[j].second) + a[j].first;
			if(a[i].first > a[j].first)swap(x,y);
			if(x > y){
				grid[i][j] = 1;
				grid[j][i] = 1;
			}
		}
	}

	dp[n-1] = 1;
	for(int i=n-2;i>=0;i--){
		for(int j=i+1;j<n;j++){
			int cnt = 0;
			for(int k=j;k<n;k++){
				if(grid[i][k] == 0 && grid[j][k] == 1)cnt++;
			}
			dp[i] = max(dp[i], dp[j] + 1 - cnt);
		}
		maxi = max(maxi, dp[i]);
	}
	cout << maxi;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 308 KB Output is correct
4 Correct 1 ms 312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 440 KB Output is correct
2 Correct 2 ms 596 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Correct 2 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 596 KB Output is correct
2 Correct 5 ms 692 KB Output is correct
3 Correct 3 ms 596 KB Output is correct
4 Correct 5 ms 692 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 852 KB Output is correct
2 Correct 14 ms 1068 KB Output is correct
3 Correct 13 ms 1004 KB Output is correct
4 Correct 10 ms 852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 42 ms 1236 KB Output is correct
2 Correct 19 ms 1104 KB Output is correct
3 Correct 34 ms 1180 KB Output is correct
4 Correct 22 ms 1108 KB Output is correct