結果

問題 No.698 ペアでチームを作ろう
ユーザー AuthnsAuthns
提出日時 2020-10-18 19:39:15
言語 Fortran
(gFortran 13.2.0)
結果
AC  
実行時間 4 ms / 1,000 ms
コード長 598 bytes
コンパイル時間 1,618 ms
コンパイル使用メモリ 27,812 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-28 12:02:37
合計ジャッジ時間 1,320 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 4 ms
4,376 KB
testcase_06 AC 4 ms
4,376 KB
testcase_07 AC 4 ms
4,380 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 4 ms
4,380 KB
testcase_10 AC 4 ms
4,380 KB
testcase_11 AC 4 ms
4,380 KB
testcase_12 AC 4 ms
4,376 KB
testcase_13 AC 4 ms
4,380 KB
testcase_14 AC 4 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,n2,s,ns,i,j,f
    integer(int32), allocatable:: a(:),dp(:)

    read*, n
    n2 = lshift(1,n)-1
    allocate(a(n))
    allocate(dp(0:n2), source=0)
    read*, a(:)
    do s=0,n2
        do i=1,n-1
            if (btest(s,i-1)) cycle
            do j=i+1,n
                if (btest(s,j-1)) cycle
                ns = ibset(ibset(s,i-1),j-1)
                f = xor(a(i),a(j))
                dp(ns) = max(dp(ns), dp(s)+f)
            end do
        end do
    end do
    print'(i0)', dp(n2)
end program main
0