結果

問題 No.1905 PURE PHRASE
ユーザー legosuke
提出日時 2022-04-15 22:29:31
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 18 ms / 2,000 ms
コード長 703 bytes
コンパイル時間 1,931 ms
コンパイル使用メモリ 200,020 KB
最終ジャッジ日時 2025-01-28 18:23:24
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 38
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int64_t cost(vector<int>& A, int p) {
    int64_t res = 0;
    for (int i = 0; i < p; ++i) {
        res += abs(A[i] - A[i + p]);
    }
    return res;
}

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    vector<int64_t> c(7);
    vector<double> H = {261.6, 294.3, 327.0, 348.8, 392.4, 436.0, 490.5};
    int ans = -1;
    for (int i = 0; i < 7; ++i) {
        int p = N / H[i];
        c[i] = cost(A, p);
        if (ans == -1 || c[i] < c[ans]) {
            ans = i;
        }
    }
    vector<string> s = {"C4", "D4", "E4", "F4", "G4", "A4", "B4"};
    cout << s[ans] << endl;
}
0