結果

問題 No.1905 PURE PHRASE
ユーザー dn6049949dn6049949
提出日時 2022-04-15 22:00:48
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 162 ms / 2,000 ms
コード長 1,048 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 10,864 KB
実行使用メモリ 36,460 KB
最終ジャッジ日時 2023-08-26 07:55:53
合計ジャッジ時間 8,355 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 160 ms
36,208 KB
testcase_01 AC 156 ms
36,332 KB
testcase_02 AC 156 ms
36,280 KB
testcase_03 AC 156 ms
36,212 KB
testcase_04 AC 157 ms
36,196 KB
testcase_05 AC 155 ms
36,408 KB
testcase_06 AC 155 ms
36,236 KB
testcase_07 AC 153 ms
36,352 KB
testcase_08 AC 155 ms
36,288 KB
testcase_09 AC 155 ms
36,236 KB
testcase_10 AC 155 ms
36,228 KB
testcase_11 AC 155 ms
36,236 KB
testcase_12 AC 157 ms
36,320 KB
testcase_13 AC 153 ms
36,356 KB
testcase_14 AC 155 ms
36,288 KB
testcase_15 AC 153 ms
36,316 KB
testcase_16 AC 154 ms
36,240 KB
testcase_17 AC 153 ms
36,288 KB
testcase_18 AC 154 ms
36,188 KB
testcase_19 AC 155 ms
36,172 KB
testcase_20 AC 157 ms
36,176 KB
testcase_21 AC 154 ms
36,316 KB
testcase_22 AC 153 ms
36,196 KB
testcase_23 AC 154 ms
36,240 KB
testcase_24 AC 154 ms
36,248 KB
testcase_25 AC 155 ms
36,196 KB
testcase_26 AC 162 ms
36,356 KB
testcase_27 AC 154 ms
36,252 KB
testcase_28 AC 158 ms
36,440 KB
testcase_29 AC 155 ms
36,328 KB
testcase_30 AC 156 ms
36,236 KB
testcase_31 AC 157 ms
36,264 KB
testcase_32 AC 156 ms
36,352 KB
testcase_33 AC 154 ms
36,332 KB
testcase_34 AC 153 ms
36,284 KB
testcase_35 AC 156 ms
36,296 KB
testcase_36 AC 155 ms
36,184 KB
testcase_37 AC 158 ms
36,252 KB
testcase_38 AC 160 ms
36,460 KB
testcase_39 AC 155 ms
36,276 KB
testcase_40 AC 155 ms
36,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
import numpy as np
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def IR(n):
    return [I() for _ in range(n)]
def LIR(n):
    return [LI() for _ in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007


hz = [261.6, 294.3, 327.0, 348.8, 392.4, 436.0, 490.5]
ch = ["C4", "D4", "E4", "F4", "G4", "A4", "B4"]


def main():
    n = I()
    a = np.array(LI())
    han = np.hanning(n)

    F = np.fft.fft(a*han)
    freq = np.fft.fftfreq(n, d=1)

    acf = np.fft.ifft(np.abs(F)**2).real

    max_ = 0
    argmax = None
    for index,f in enumerate(hz):
        i = round(n/f)
        s = 0
        for j in range(i-3,i+4):
            s = max(s,abs(acf[j]))
        if max_ < s:
            max_ = s
            argmax = index
    print(ch[argmax])

    return


if __name__ == "__main__":
    main()
0