結果
| 問題 | No.3658 Darumaka Number 2 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-09-16 03:24:37 |
| 言語 | C++23 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 2 ms / 2,000 ms |
| + 12µs | |
| コード長 | 870 bytes |
| 記録 | |
| コンパイル時間 | 2,546 ms |
| コンパイル使用メモリ | 335,068 KB |
| 実行使用メモリ | 6,528 KB |
| 最終ジャッジ日時 | 2026-09-16 03:24:45 |
| 合計ジャッジ時間 | 5,421 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 45 |
ソースコード
#include <bits/stdc++.h>
using i64 = long long;
using u64 = unsigned long long;
using u32 = unsigned;
using u128 = unsigned __int128;
using i128 = __int128;
void solve() {
std::string N; std::cin >> N;
int n = (int)N.size();
std::string ans = "";
int a = -1;
for(int i = 0; i < n; i ++) {
int x = N[i] - '0';
if(x > 5) {
for(int j = i; j < n; j ++) ans += '5';
break;
} else if(x < 4) {
if(a == -1) {
ans = "";
for(int j = 0; j < n - 1; j ++) ans += '5';
} else {
ans[a] = '4';
for(int j = a + 1; j < i; j ++) ans[j] = '5';
for(int j = i; j < n; j ++) ans += '5';
}
break;
} else {
ans += N[i];
if(N[i] == '5') a = i;
}
}
std::cout << ans;
}
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int T = 1;
//std::cin >> T;
while (T--) {
solve();
}
return 0;
}