#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 time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
316 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |