Submission #639361

#TimeUsernameProblemLanguageResultExecution timeMemory
639361starchan걷기 (NOI12_walking)C++17
0 / 25
2 ms340 KiB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define in pair<int, int>
#define f first
#define s second
#define pb push_back
#define pob pop_back
#define INF (int)1e17
#define MX (int)3e5+5
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
signed main()
{
	fast();
	int l, n;
	cin >> l >> n;
	vector<in> t(n+1);
	t[0] = {0,0};
	vector<int> v(n+1);
	vector<int> dp(n+1);
	for(int i = 1; i <= n; i++)
	{
		cin >> t[i].f;
		t[i].s = i;
	}
	for(int i = 1; i <= n; i++)
		cin >> v[i];
	sort(t.begin(), t.end());
	dp[1] = 1;
	for(int i = 2; i <= n; i++)
	{
		dp[i] = 0;
		for(int j = 1; j < i; j++)
		{
			int prod = v[t[i].s]*v[t[j].s];
			if((l*v[t[j].s] + t[i].f*prod) > (l*v[t[i].s] + t[j].f*prod))
				dp[i] = max(dp[i], dp[j]);
		}
		dp[i]++;
	}
	cout << dp[n];
	return 0;
}	
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...