結果
| 問題 | No.3658 Darumaka Number 2 |
| コンテスト | |
| ユーザー |
rinrion
|
| 提出日時 | 2026-08-30 15:58:34 |
| 言語 | C++14 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,520 bytes |
| 記録 | |
| コンパイル時間 | 2,617 ms |
| コンパイル使用メモリ | 247,104 KB |
| 実行使用メモリ | 6,272 KB |
| 最終ジャッジ日時 | 2026-08-30 15:58:42 |
| 合計ジャッジ時間 | 5,295 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 WA * 25 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<ll, ll>>;
#define rep(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define repr(i, s, n) for (int i = (s); i >= (int)(n); --i)
#define sz(x) ((int)(x).size())
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
auto _ = []{ios::sync_with_stdio(false); cin.tie(nullptr); return 0;}();
const int INFI = 1 << 30;
const ll INFL = 1LL << 62;
int main() {
string s;
cin >> s;
int n=sz(s);
bool jdg = 1;
for (auto x : s){
if((x - '0')<5){
jdg=0;
break;
}
}
if(jdg){
rep (i, 0, n){
cout<<5;
}
cout << '\n';
return 0;
}
if((s[0] - '0'<=4)){
jdg = 1;
for (auto x : s){
if((x - '0')<4){
jdg=0;
break;
}
}
if(!jdg){
rep (i, 0, n-1){
cout<<5;
}
cout << '\n';
return 0;
}
}
string ans="";
jdg=0;
reverse (s.begin(), s.end());
for (auto x : s){
if(jdg){
x=(char)(((x - '0')-1)+'0');
jdg=0;
}
if((x - '0')==4)ans.push_back (x);
else if((x - '0')>=5)ans.push_back ('5');
else{
ans.push_back ('5');
jdg=1;
}
}
reverse (ans.begin(), ans.end());
cout << ans << '\n';
return 0;
}
rinrion