結果
| 問題 | No.357 品物の並び替え (Middle) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-10-18 19:58:09 |
| 言語 | Fortran (gFortran 14.2.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 5,000 ms |
| コード長 | 637 bytes |
| 記録 | |
| コンパイル時間 | 1,568 ms |
| コンパイル使用メモリ | 34,048 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-21 06:42:29 |
| 合計ジャッジ時間 | 1,020 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 18 |
ソースコード
program main
use,intrinsic :: iso_fortran_env
implicit none
integer(int32)n,m,n2,s,ns,i,j
integer(int32):: i1,i2,sc
integer(int32), allocatable:: score(:,:),dp(:)
read*, n,m
allocate(score(n,n), source=0)
do i=1,m
read*, i1,i2,sc
score(i1+1,i2+1) = sc
end do
n2 = lshift(1,n)-1
allocate(dp(0:n2),source=0)
do s=0,n2
do i=1,n
if (btest(s,i-1)) cycle
ns = ibset(s,i-1)
sc=sum([(merge(score(i,j),0,btest(s,j-1)),j=1,n)])
dp(ns) = max(dp(ns), dp(s)+sc)
end do
end do
print'(i0)', dp(n2)
end program main