#include "fish.h"
#include<bits/stdc++.h>
using namespace std;
int Graph[302][10]={{0}};
long long int dp[9][9]={{0}};
long long int tmp[9][9]={{0}};
long long int Count(int n,int m,int column){
long long int answer=0;
for(int i=n;i<=m;i++){
answer+=Graph[column][i];
}
return answer;
}
void check(){
cout<<endl;
for(int i=0;i<9;i++){
for(int j=0;j<9;j++){
cout<<dp[i][j]<<" ";
}
cout<<endl;
}
}
long long int max_weights(int N,int M,vector<int> x,vector<int> y,vector<int> w){
for(int i=0;i<M;i++){
Graph[x[i]][y[i]]=w[i];
}
for(int i=0;i<9;i++){
for(int j=0;j<9;j++){
dp[i][j]=Count(i+1,j,0);
}
}
//check();
for(int i=1;i<N-1;i++){
for(int j=0;j<9;j++){
for(int k=0;k<9;k++){
for(int I=0;I<9;I++){
tmp[j][k]=max(tmp[j][k],dp[I][j]+Count(j+1,max(k,I),i));
}
}
}
for(int j=0;j<9;j++){
for(int k=0;k<9;k++){
dp[j][k]=tmp[j][k];
tmp[j][k]=0;
}
}
//check();
}
long long int Final=0;
for(int j=0;j<9;j++){
for(int k=0;k<9;k++){
dp[j][k]+=Count(k+1,j,N-1);
Final=max(Final,dp[j][k]);
}
}
//check();
return Final;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
23 ms |
4308 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '2', found: '1' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
1st lines differ - on the 1st token, expected: '3', found: '2' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
340 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
23 ms |
4308 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |