結果
問題 | No.1905 PURE PHRASE |
ユーザー |
👑 ![]() |
提出日時 | 2022-04-15 21:32:37 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 13 ms / 2,000 ms |
コード長 | 1,343 bytes |
コンパイル時間 | 1,277 ms |
コンパイル使用メモリ | 100,272 KB |
最終ジャッジ日時 | 2025-01-28 17:57:25 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <atcoder/modint> using namespace std; using i32 = int; using u32 = unsigned int; using i64 = long long; using u64 = unsigned long long; #define rep(i,n) for(int i=0; i<(int)(n); i++) using m32 = atcoder::modint998244353; int main(){ int N; cin >> N; vector<double> A(N); rep(i,N){ int a; cin >> a; A[i] = a; } vector<pair<double, string>> tones = { { 261.6 , "C4" }, { 294.3 , "D4" }, { 327.0 , "E4" }, { 348.8 , "F4" }, { 392.4 , "G4" }, { 436.0 , "A4" }, { 490.5 , "B4" } }; auto f = [&](double p) -> double { double l = A[floor(p)]; double r = A[ceil(p)]; double x = p - floor(p); return l + (r-l) * x; }; pair<double, int> ans = { 1e100, 0 }; rep(ty,tones.size()){ double dt = 44100.0 / tones[ty].first; double diff = 0; for(int i=0; i<N-300; i++){ double dy = abs(A[i] - f(i+dt)); diff += dy * dy; } ans = min(ans, make_pair(diff, ty)); } cout << tones[ans.second].second << endl; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ std::ios::sync_with_stdio(false); std::cin.tie(nullptr); } } ios_do_not_sync_instance;