#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define pb push_back
#define pf push_front
#define pi pair<int,int>
#define vi vector<int>
int n ;
vi x, y;
ll init(int N, int X[], int Y[]){
n = N;
x.resize(N);
y.resize(N);
for(int i =0; i < n; i++){
x[i] =X[i];
y[i] = Y[i];
}
ll final = 0;
ll dp[n+10][10002];
for(int i = 0; i <= n; i++){
for(int j= 0; j < 10001;j++){
dp[i][j]=-LLONG_MAX;
}
}
dp[0][1]=0;
for(int i = 1; i <= n; i++){
//dp[0][i] =dp[0][i-1];
for(int j = 0; j < 1001; j++){
for(int k = 0; k <= (j+(j*x[i-1])); k++){
ll have = j*x[i-1];
if(have>10000)break;
// cout << i << " "<<j << " " << dp[i-1][j]<<endl;
if(dp[i-1][j] >=0) dp[i][have-k] = max(dp[i][have-k] ,dp[i-1][j] + (y[i-1] * k));
}
}
}
ll ans = 0;
// cout << dp[n][0]<<endl;
for(int i = 0; i <n; i++){
ans = max(ans,dp[i][0]);
}
for(int i = 0; i < 10001; i++){
// cout <<i<<" "<< dp[n][i]<<endl;
ans= max(ans,dp[n][i]);
}
return ans;
}
void updateX(int pos, int val){
x[pos]=val;
}
void updateY(int pos, int val){
y[pos]=val;
}
Compilation message
horses.cpp: In function 'long long int init(int, int*, int*)':
horses.cpp:24:8: warning: unused variable 'final' [-Wunused-variable]
24 | ll final = 0;
| ^~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1116 KB |
Output is correct |
2 |
Correct |
15 ms |
1992 KB |
Output is correct |
3 |
Correct |
18 ms |
1884 KB |
Output is correct |
4 |
Correct |
11 ms |
1884 KB |
Output is correct |
5 |
Correct |
8 ms |
2000 KB |
Output is correct |
6 |
Correct |
9 ms |
1884 KB |
Output is correct |
7 |
Correct |
26 ms |
2000 KB |
Output is correct |
8 |
Correct |
19 ms |
1996 KB |
Output is correct |
9 |
Correct |
9 ms |
1884 KB |
Output is correct |
10 |
Correct |
8 ms |
1880 KB |
Output is correct |
11 |
Correct |
4 ms |
1372 KB |
Output is correct |
12 |
Correct |
1 ms |
1136 KB |
Output is correct |
13 |
Correct |
9 ms |
1756 KB |
Output is correct |
14 |
Correct |
4 ms |
1116 KB |
Output is correct |
15 |
Correct |
3 ms |
1372 KB |
Output is correct |
16 |
Correct |
16 ms |
1996 KB |
Output is correct |
17 |
Correct |
5 ms |
1460 KB |
Output is correct |
18 |
Correct |
7 ms |
1528 KB |
Output is correct |
19 |
Correct |
7 ms |
1628 KB |
Output is correct |
20 |
Correct |
14 ms |
1976 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1116 KB |
Output is correct |
2 |
Correct |
15 ms |
1884 KB |
Output is correct |
3 |
Correct |
19 ms |
1988 KB |
Output is correct |
4 |
Correct |
10 ms |
1880 KB |
Output is correct |
5 |
Correct |
6 ms |
1884 KB |
Output is correct |
6 |
Correct |
8 ms |
1884 KB |
Output is correct |
7 |
Correct |
17 ms |
1884 KB |
Output is correct |
8 |
Correct |
19 ms |
1992 KB |
Output is correct |
9 |
Correct |
9 ms |
1972 KB |
Output is correct |
10 |
Correct |
8 ms |
2136 KB |
Output is correct |
11 |
Correct |
4 ms |
1372 KB |
Output is correct |
12 |
Correct |
1 ms |
1116 KB |
Output is correct |
13 |
Correct |
10 ms |
1628 KB |
Output is correct |
14 |
Correct |
5 ms |
1116 KB |
Output is correct |
15 |
Correct |
3 ms |
1372 KB |
Output is correct |
16 |
Correct |
17 ms |
1996 KB |
Output is correct |
17 |
Correct |
5 ms |
1628 KB |
Output is correct |
18 |
Correct |
8 ms |
1372 KB |
Output is correct |
19 |
Correct |
6 ms |
1628 KB |
Output is correct |
20 |
Correct |
14 ms |
1880 KB |
Output is correct |
21 |
Incorrect |
31 ms |
1976 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
224 ms |
524288 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
1116 KB |
Output is correct |
2 |
Correct |
13 ms |
1988 KB |
Output is correct |
3 |
Correct |
16 ms |
1884 KB |
Output is correct |
4 |
Correct |
9 ms |
1940 KB |
Output is correct |
5 |
Correct |
7 ms |
1996 KB |
Output is correct |
6 |
Correct |
8 ms |
1884 KB |
Output is correct |
7 |
Correct |
25 ms |
1988 KB |
Output is correct |
8 |
Correct |
19 ms |
1880 KB |
Output is correct |
9 |
Correct |
7 ms |
1884 KB |
Output is correct |
10 |
Correct |
7 ms |
2004 KB |
Output is correct |
11 |
Correct |
3 ms |
1368 KB |
Output is correct |
12 |
Correct |
2 ms |
1292 KB |
Output is correct |
13 |
Correct |
10 ms |
1628 KB |
Output is correct |
14 |
Correct |
4 ms |
1292 KB |
Output is correct |
15 |
Correct |
3 ms |
1372 KB |
Output is correct |
16 |
Correct |
16 ms |
2000 KB |
Output is correct |
17 |
Correct |
5 ms |
1628 KB |
Output is correct |
18 |
Correct |
7 ms |
1372 KB |
Output is correct |
19 |
Correct |
6 ms |
1628 KB |
Output is correct |
20 |
Correct |
12 ms |
1992 KB |
Output is correct |
21 |
Incorrect |
31 ms |
1996 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1116 KB |
Output is correct |
2 |
Correct |
14 ms |
1992 KB |
Output is correct |
3 |
Correct |
16 ms |
1884 KB |
Output is correct |
4 |
Correct |
10 ms |
1844 KB |
Output is correct |
5 |
Correct |
7 ms |
1996 KB |
Output is correct |
6 |
Correct |
8 ms |
1884 KB |
Output is correct |
7 |
Correct |
17 ms |
1884 KB |
Output is correct |
8 |
Correct |
18 ms |
1884 KB |
Output is correct |
9 |
Correct |
9 ms |
1884 KB |
Output is correct |
10 |
Correct |
7 ms |
1996 KB |
Output is correct |
11 |
Correct |
3 ms |
1204 KB |
Output is correct |
12 |
Correct |
1 ms |
1116 KB |
Output is correct |
13 |
Correct |
9 ms |
1768 KB |
Output is correct |
14 |
Correct |
4 ms |
1112 KB |
Output is correct |
15 |
Correct |
3 ms |
1372 KB |
Output is correct |
16 |
Correct |
15 ms |
2000 KB |
Output is correct |
17 |
Correct |
5 ms |
1624 KB |
Output is correct |
18 |
Correct |
8 ms |
1368 KB |
Output is correct |
19 |
Correct |
5 ms |
1624 KB |
Output is correct |
20 |
Correct |
12 ms |
1884 KB |
Output is correct |
21 |
Incorrect |
28 ms |
2004 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |