Submission #499611

# Submission time Handle Problem Language Result Execution time Memory
499611 2021-12-29T04:37:40 Z ac2hu Walking (NOI12_walking) C++14
17 / 25
1 ms 312 KB
#include<bits/stdc++.h>
using namespace std;
signed main(){
	iostream::sync_with_stdio(false);
	cin.tie(nullptr);cout.tie(nullptr);
	int l,n;cin >> l >> n;
	vector<pair<int,int>> inp(n);
	for(int i = 0;i<n;i++){
		cin >> inp[i].first >> inp[i].second;
	}
	sort(inp.begin(),inp.end());
	vector<int> finish(n);
	for(int i = 0;i<n;i++){
		finish[i] = l/inp[i].second + inp[i].first;
	}
	// for(int &e : finish)cout << e << "\n";
	vector<int> dp(n);
	for(int i = 0;i<n;i++){
		dp[i] = 1;
		for(int j = i-1;j>=0;j--){
			if(finish[j] > finish[i])
				dp[i] = max(dp[j] + 1,dp[i]);
		}
	}
	cout << *max_element(dp.begin(),dp.end()) << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Incorrect 0 ms 204 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 312 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 304 KB Output is correct
3 Incorrect 1 ms 204 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 216 KB Output is correct
2 Correct 1 ms 312 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct