Task: | putnik |
Sender: | Hansuzu |
Submission time: | 2016-08-01 16:25:59 +0300 |
Language: | C++ |
Status: | READY |
Result: | 100 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 100 |
test | verdict | time | |
---|---|---|---|
#1 | ACCEPTED | 0.05 s | details |
#2 | ACCEPTED | 0.05 s | details |
#3 | ACCEPTED | 0.05 s | details |
#4 | ACCEPTED | 0.05 s | details |
#5 | ACCEPTED | 0.05 s | details |
#6 | ACCEPTED | 0.06 s | details |
#7 | ACCEPTED | 0.64 s | details |
#8 | ACCEPTED | 0.64 s | details |
Code
#include <iostream> using namespace std; int N; int dp[1515][1515]; int rt[1515][1515]; int main(){ cin >> N; for (int i=0; i<N; ++i){ for (int j=0; j<N; ++j){ cin >> rt[i][j]; } } dp[1][0]=rt[1][0]; for (int i=2; i<N; ++i){ dp[i][i-1]=1222333444; for (int j=0; j<i-1; ++j){ dp[i][j]=dp[i-1][j]+rt[i][i-1]; dp[i][i-1]=min(dp[i][i-1], dp[i-1][j]+rt[i][j]); } } int ans=1222333444; for (int i=0; i<N-1; ++i) ans=min(ans, dp[N-1][i]); cout << ans << "\n"; }
Test details
Test 1
Verdict: ACCEPTED
input |
---|
3
0 5 2 5 0 4 2 4 0 |
correct output |
---|
7 |
user output |
---|
7 |
Test 2
Verdict: ACCEPTED
input |
---|
4
0 15 7 8 15 0 16 9 7 16 0 12 8 9 12 0 |
correct output |
---|
31 |
user output |
---|
31 |
Test 3
Verdict: ACCEPTED
input |
---|
5
0 929 320 220 170 929 0 16 856 166 320 16 0 989 554 220 856 989 0 695 ... |
correct output |
---|
1719 |
user output |
---|
1719 |
Test 4
Verdict: ACCEPTED
input |
---|
8
0 506 801 997 312 671 746 780 506 0 634 349 891 378 259 767 801 634 0 806 899 355 545 800 997 349 806 0 780 454 434 962 ... |
correct output |
---|
3214 |
user output |
---|
3214 |
Test 5
Verdict: ACCEPTED
input |
---|
16
0 432 752 452 683 655 785 402 ... |
correct output |
---|
4696 |
user output |
---|
4696 |
Test 6
Verdict: ACCEPTED
input |
---|
300
0 118 579 90 535 606 866 184 1... |
correct output |
---|
88301 |
user output |
---|
88301 |
Test 7
Verdict: ACCEPTED
input |
---|
1500
0 27 341 796 776 497 727 796 5... |
correct output |
---|
440136 |
user output |
---|
440136 |
Test 8
Verdict: ACCEPTED
input |
---|
1499
0 674 891 871 992 186 562 169 ... |
correct output |
---|
426711 |
user output |
---|
426711 |