結果

問題 No.412 花火大会
ユーザー 37zigen37zigen
提出日時 2018-04-22 00:37:01
言語 Fortran
(gFortran 13.2.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,415 bytes
コンパイル時間 251 ms
コンパイル使用メモリ 29,108 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-09 12:26:49
合計ジャッジ時間 1,283 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

module mdl
contains
    recursive subroutine qsort(a,s,t)
        integer*8::a(:),s,t,i,j,m
        if(t-s<=1)return
        i=s
        j=t-1
        m=a((s+t)/2)
        do
            do while(a(i)<m)
                i=i+1
            end do
            do while(a(j)>m)
                j=j-1
            end do
            if(i>=j)exit
            a(i)=xor(a(i),a(j))
            a(j)=xor(a(i),a(j))
            a(i)=xor(a(i),a(j))
            i=i+1
            j=j-1
        end do
        call qsort(a,s,i)
        call qsort(a,j+1,t)
    end subroutine

end module


program main
    use mdl
    implicit none
    integer*8::B,C,D,N,i,j,k,p,ans=0,arr(3),a(3),dp(0:30,0:7)
    integer*8,allocatable::E(:)
    logical::flag
    read(*,*)B,C,D
    a(1)=B
    a(2)=C
    a(3)=D
    call qsort(a,1_8,4_8)
    read*,N
    allocate(E(N))
    read*,(E(i),i=1,N)
    do i=0,30
        do j=0,7
            dp(i,j)=0
        end do
    end do
    dp(0,0)=1
    do i=1,N
        do j=0,7
            flag=.false.
            do k=0,2
                if(mod(rshift(j,k),2)==1.or.a(3-k)>E(i))cycle
                dp(i,or(j,lshift(1,k)))=dp(i,or(j,lshift(1,k)))+dp(i-1,j)
                flag=.true.
                exit
            end do
            if(.not.flag)dp(i,j)=dp(i,j)+dp(i-1,j)
        end do
        do j=0,7
            dp(i,j)=dp(i,j)+dp(i-1,j)
        end do
    end do


    print*,dp(N,7)

end program
0