結果
| 問題 |
No.636 硬貨の枚数2
|
| コンテスト | |
| ユーザー |
merom686
|
| 提出日時 | 2018-01-19 23:15:30 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 873 bytes |
| コンパイル時間 | 875 ms |
| コンパイル使用メモリ | 75,240 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-24 12:52:17 |
| 合計ジャッジ時間 | 2,425 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 29 WA * 36 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int main() {
string s;
cin >> s;
int n = s.size();
reverse(s.begin(), s.end());
s.push_back('0');
int r = 0;
for (int i = 0; i < n; i++) {
int a = s[i] - '0';
int b = s[i + 1] - '0';
int a0 = a % 5, a1 = a / 5;
int b0 = b % 5, b1 = b / 5;
int c0 = 0, c1 = 0;
if (a0 <= 3 - (a1 > 0)) {
r += a0;
} else {
c0 = 1;
r += 5 - a0;
}
a1 += c0;
if (a1 <= 1 - (b0 > 2)) {
r += a1;
} else {
c1 = 1;
r += 2 - a1;
}
s[i + 1] += c1;
}
if (s[n] -= '0') {
r += s[n];
}
cout << r << endl;
return 0;
}
merom686