結果
| 問題 | No.3658 Darumaka Number 2 |
| コンテスト | |
| ユーザー |
こっとん
|
| 提出日時 | 2026-08-30 20:37:09 |
| 言語 | C++23(gcc16) (gcc 16.1.0 + boost 1.92.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,931 bytes |
| 記録 | |
| コンパイル時間 | 4,165 ms |
| コンパイル使用メモリ | 389,532 KB |
| 実行使用メモリ | 9,808 KB |
| 最終ジャッジ日時 | 2026-08-30 20:37:24 |
| 合計ジャッジ時間 | 7,032 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 39 WA * 6 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
using V = vector<ll>;
using P = pair<ll, ll>;
using i128 = __int128;
using mint = atcoder::modint998244353;
// using mint = atcoder::modint1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; i--)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define UNIQUE(a) sort(all(a)), (a).erase(unique(all(a)), (a).end())
#define YES cout << "Yes" << '\n'
#define NO cout << "No" << '\n'
inline void Yn(bool b) { cout << (b ? "Yes" : "No") << '\n'; }
template <class T, class U> bool chmax(T& x, const U& y) {
if (x < y) { x = y; return true; }
return false;
}
template <class T, class U> bool chmin(T& x, const U& y) {
if (y < x) { x = y; return true; }
return false;
}
const ll INF = 1e18;
const int IINF = 1e9;
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, 1, -1};
void solve() {
string s; cin >> s;
string ans = "";
int n = s.size();
int small = -1,u = -1;
rep(i,n){
if(s[i]-'0' < 4) {
small = i; break;
}
}
rep(i,small){
if(s[i] == '5') u = i;
}
rep(i,n){
if(s[i]-'0' > 5){
rep(j,n-i) ans.push_back('5');
break;
}
else if(i == small && u != -1){
rep(j,small-u) ans.pop_back();
ans.push_back('4');
rep(j,n-i) ans.push_back('5');
break;
}
else if(s[i]-'0' < 4){
rep(j,n-i-1) ans.push_back('5');
break;
}
else{
ans.push_back(s[i]);
}
}
cout << ans << endl;
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int t = 1;
//cin >> t;
while (t--) solve();
}
こっとん