結果
問題 | No.2775 Nuisance Balls |
ユーザー |
![]() |
提出日時 | 2024-06-08 00:10:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 63 ms / 2,000 ms |
コード長 | 792 bytes |
コンパイル時間 | 2,046 ms |
コンパイル使用メモリ | 195,936 KB |
最終ジャッジ日時 | 2025-02-21 20:39:21 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; const int INF = 1e9 + 10; const ll INFL = 4e18; int main() { int N; cin >> N; int M = 6; vector<int> A = {1, 6, 30, 180, 360, 720}; string S = ".oRSMC"; vector<int> dp(N + 1, INF); dp[0] = 0; for (int i = 0; i < N; i++) { for (int x : A) { if (i + x <= N) { dp[i + x] = min(dp[i + x], dp[i] + 1); } } } string ans; int now = N; while (now > 0) { for (int i = 0; i < M; i++) { if (dp[now - A[i]] == dp[now] - 1) { ans.push_back(S[i]); now -= A[i]; break; } } } reverse(ans.begin(), ans.end()); cout << ans << endl; }