結果

問題 No.1905 PURE PHRASE
ユーザー 👑 hitonanodehitonanode
提出日時 2022-02-23 13:25:24
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 988 bytes
コンパイル時間 800 ms
コンパイル使用メモリ 89,968 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 05:44:37
合計ジャッジ時間 2,517 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
4,380 KB
testcase_01 AC 5 ms
4,376 KB
testcase_02 AC 6 ms
4,376 KB
testcase_03 AC 5 ms
4,380 KB
testcase_04 AC 5 ms
4,376 KB
testcase_05 AC 6 ms
4,380 KB
testcase_06 AC 5 ms
4,380 KB
testcase_07 AC 6 ms
4,376 KB
testcase_08 AC 6 ms
4,376 KB
testcase_09 AC 5 ms
4,380 KB
testcase_10 AC 5 ms
4,376 KB
testcase_11 AC 5 ms
4,376 KB
testcase_12 AC 5 ms
4,376 KB
testcase_13 AC 5 ms
4,380 KB
testcase_14 AC 6 ms
4,380 KB
testcase_15 AC 5 ms
4,376 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 5 ms
4,380 KB
testcase_18 AC 6 ms
4,376 KB
testcase_19 AC 5 ms
4,376 KB
testcase_20 AC 5 ms
4,376 KB
testcase_21 AC 5 ms
4,376 KB
testcase_22 AC 5 ms
4,376 KB
testcase_23 AC 5 ms
4,376 KB
testcase_24 AC 5 ms
4,376 KB
testcase_25 AC 5 ms
4,380 KB
testcase_26 AC 5 ms
4,376 KB
testcase_27 AC 5 ms
4,376 KB
testcase_28 AC 5 ms
4,376 KB
testcase_29 AC 5 ms
4,376 KB
testcase_30 AC 6 ms
4,376 KB
testcase_31 AC 5 ms
4,380 KB
testcase_32 AC 5 ms
4,380 KB
testcase_33 AC 5 ms
4,376 KB
testcase_34 AC 6 ms
4,380 KB
testcase_35 AC 6 ms
4,376 KB
testcase_36 AC 5 ms
4,376 KB
testcase_37 AC 5 ms
4,380 KB
testcase_38 AC 5 ms
4,380 KB
testcase_39 AC 5 ms
4,376 KB
testcase_40 AC 6 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// \sum_i sgn(A_i)sgn(B_i) 最大化
#include <iostream>
#include <vector>
using namespace std;

const vector<double> freqs{261.6, 294.3, 327.0, 348.8, 392.4, 436.0, 490.5};

template <class T>
int sgn(T x) {
    if (x > 0) return 1;
    if (x < 0) return -1;
    return 0;
}

int main() {
    cin.tie(nullptr), ios::sync_with_stdio(false);

    int N;
    cin >> N;
    vector<short> A(N);
    for (auto &x : A) cin >> x;

    int bestscore = -100000000;
    int argbest = -1;
    for (int d = 0; d < freqs.size(); ++d) {
        int score = 0;

        // freq[d] Hz -> 長さ N で freq[d] 周期 -> 一周期 period は N / freq[d] 要素分
        int period = N / freqs[d];

        for (int i = 0; i < N / 2; ++i) {
            score += sgn(A[i]) * sgn(A[i + period]);
        }
        if (score > bestscore) {
            bestscore = score;
            argbest = d;
        }
    }
    cout << (char)('A' + (2 + argbest) % 7) << "4\n";
}
0