#include "fish.h"
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cmath>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<int, int> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<ld> vd;
typedef vector<long long> vl;
typedef vector<vl> vvl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i, a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)
#define len(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define nl endl
#define S second
#define lb lower_bound
#define ub upper_bound
#define aint(x) x.begin(), x.end()
#define raint(x) x.rbegin(), x.rend()
#define ins insert
const int MOD = 1000000007;
long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
ll ans = 0;
vvl dp(N+5,vl(N+5,0));
vvl arr(N+5,vl(N+5,0));
FOR(i,0,M){
arr[X[i]][Y[i]] = W[i];
}
// cout << endl;
// FOR(i,0,N){
// FOR(j,0,N){
// cout << arr[i][j] << " ";
// }
// cout << endl;
// }
// cout <<endl;
FOR(i,0,N){
FOR(j,-1,N+1){
ll temp = 0,added = 0;
if(j == -1){
if(i>0){
FOR(k,-1,N+1){
temp = max(temp,dp[i-1][k+1]);
}
}
dp[i][j+1] = temp;
continue;
}
FOR(k,0,j+1){
if(i<N-1)
added += arr[i+1][k];
if(i==1)
added += arr[0][k];
}
temp = max(temp,added);
if(i == 0){
dp[i][j+1] = temp;
continue;
}
temp = max(temp,added+dp[i-1][0]);
FOR(k,1,N+1){
if(k-1<j+1){
added -= arr[i][k-1];
}
temp = max(temp,added+dp[i-1][k]);
}
dp[i][j+1] = temp;
}
}
FOR(i,0,N){
FOR(j,0,N+1){
// cout << dp[i][j] << " ";
ans = max(ans,dp[i][j]);
}
// cout << endl;
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
874 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Runtime error |
826 ms |
2097152 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
777 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
777 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
874 ms |
2097152 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |