結果
| 問題 |
No.1905 PURE PHRASE
|
| コンテスト | |
| ユーザー |
hitonanode
|
| 提出日時 | 2022-02-23 13:25:24 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 2,000 ms |
| コード長 | 988 bytes |
| コンパイル時間 | 911 ms |
| コンパイル使用メモリ | 89,432 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-01 13:20:00 |
| 合計ジャッジ時間 | 2,477 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
// \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";
}
hitonanode