//by szh
#include<bits/stdc++.h>
#include "fish.h"
using namespace std;
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl
#define pq priority_queue
#define inf 0x3f
#define rep(i,a,b) for (int i=a;i<(b);i++)
#define MP make_pair
#define SZ(x) (int(x.size()))
#define ll long long
#define mod 1000000007
#define ALL(x) x.begin(),x.end()
void inc(int &a,int b) {a=(a+b)%mod;}
void dec(int &a,int b) {a=(a-b+mod)%mod;}
int lowbit(int x) {return x&(-x);}
ll p0w(ll base,ll p) {ll ret=1;while(p>0){if (p%2ll==1ll) ret=ret*base%mod;base=base*base%mod;p/=2ll;}return ret;}
const int maxn = 3010;
ll dp[maxn][maxn][2];
int y[maxn];
int w[maxn][maxn];
int xmax,ymax;
long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y,std::vector<int> W) {
rep(i,0,M) {
y[i] = Y[i];
y[i]++;
w[X[i]][y[i]]=W[i];
xmax = max(X[i],xmax);
ymax = max(y[i],ymax);
}
ll ans = 0;
rep(i,0,N) rep(j,1,N+1) dp[i][j][0] = dp[i][j][1] = -1e18;
dp[0][0][0] = dp[0][N][1] = 0;
rep(i,1,N) {
//increasing
dp[i][0][0] = dp[i-1][0][0];
rep(j,1,N+1) {
dp[i][j][0] = max(dp[i-1][j][0],dp[i][j-1][0] + w[i-1][j]);
}
dp[i][N][1] = dp[i-1][N][1];
for (int j = N-1;j>=0;j--) {
dp[i][j][1] = max(dp[i-1][j][1],dp[i][j+1][1] + w[i][j+1]);
}
dp[i][0][0] = max(dp[i][0][0],dp[i-1][0][1]);
ll tmp = 0;
rep(j,1,N+1) tmp += w[i-1][j];
if (i-2>=0) dp[i][N][1] = max(dp[i][N][1],dp[i-2][N][1]+tmp);
dp[i][N][0] = dp[i][N][1] = max(dp[i][N][0],dp[i][N][1]);
rep(j,0,N+1) {
ans = max(ans,max(dp[i][j][0],dp[i][j][1]));
// cout<<i<<" "<<j<<" "<<dp[i][j][0]<<" "<<dp[i][j][1];debug(w[i][1]);
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
397 ms |
293756 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Runtime error |
440 ms |
299344 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
393 ms |
287956 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
304 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
308 KB |
Output is correct |
9 |
Correct |
2 ms |
1876 KB |
Output is correct |
10 |
Correct |
3 ms |
4180 KB |
Output is correct |
11 |
Correct |
2 ms |
1856 KB |
Output is correct |
12 |
Correct |
3 ms |
4180 KB |
Output is correct |
13 |
Correct |
1 ms |
980 KB |
Output is correct |
14 |
Correct |
3 ms |
4160 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
304 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
308 KB |
Output is correct |
9 |
Correct |
2 ms |
1876 KB |
Output is correct |
10 |
Correct |
3 ms |
4180 KB |
Output is correct |
11 |
Correct |
2 ms |
1856 KB |
Output is correct |
12 |
Correct |
3 ms |
4180 KB |
Output is correct |
13 |
Correct |
1 ms |
980 KB |
Output is correct |
14 |
Correct |
3 ms |
4160 KB |
Output is correct |
15 |
Correct |
3 ms |
4052 KB |
Output is correct |
16 |
Correct |
2 ms |
852 KB |
Output is correct |
17 |
Incorrect |
15 ms |
5824 KB |
1st lines differ - on the 1st token, expected: '15950010139738', found: '16130398766174' |
18 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
304 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
308 KB |
Output is correct |
9 |
Correct |
2 ms |
1876 KB |
Output is correct |
10 |
Correct |
3 ms |
4180 KB |
Output is correct |
11 |
Correct |
2 ms |
1856 KB |
Output is correct |
12 |
Correct |
3 ms |
4180 KB |
Output is correct |
13 |
Correct |
1 ms |
980 KB |
Output is correct |
14 |
Correct |
3 ms |
4160 KB |
Output is correct |
15 |
Correct |
3 ms |
4052 KB |
Output is correct |
16 |
Correct |
2 ms |
852 KB |
Output is correct |
17 |
Incorrect |
15 ms |
5824 KB |
1st lines differ - on the 1st token, expected: '15950010139738', found: '16130398766174' |
18 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
393 ms |
287956 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
397 ms |
293756 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |