Contest Duration: ~ (local time) (100 minutes) Back to Home

Submission #10157591

Source Code Expand

Copy
```#include <bits/stdc++.h>
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
using namespace std;

int64_t solve(const string & s) {
int n = s.length();
vector<array<int64_t, 2> > dp(n + 1);
REP_R (i, n) {
int c = s[i] - '0';
int d = 9 - c + (i == n - 1);
dp[i][0] = min(c + dp[i + 1][0], c + 1 + dp[i + 1][1]);
dp[i][1] = min(d + 1 + dp[i + 1][0], d + dp[i + 1][1]);
}
return min(dp[0][0], dp[0][1] + 1);
}

int main() {
string s; cin >> s;
cout << solve(s) << endl;
return 0;
}
```

#### Submission Info

Submission Time 2020-02-16 22:18:18+0900 E - Payment kimiyuki C++14 (GCC 5.4.1) 500 557 Byte AC 40 ms 17028 KB

#### Judge Result

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
Subtask1 500 / 500 sample_01.txt, sample_02.txt, sample_03.txt, sub1_01.txt, sub1_02.txt, sub1_03.txt, sub1_04.txt, sub1_05.txt, sub1_06.txt, sub1_07.txt, sub1_08.txt, sub1_09.txt, sub1_10.txt, sub1_11.txt, sub1_12.txt, sub1_13.txt, sub1_14.txt, sub1_15.txt, sub1_16.txt, sub1_17.txt, sub1_18.txt, sub1_19.txt, sub1_20.txt, sub1_21.txt, sub1_22.txt, sub1_23.txt, sub1_24.txt, sub1_25.txt, sub1_26.txt, sub1_27.txt, sub1_28.txt, sub1_29.txt, sub1_30.txt, sub1_31.txt, sub1_32.txt, sub1_33.txt, sub1_34.txt, sub1_35.txt, sub1_36.txt, sub1_37.txt, sub1_38.txt
Case Name Status Exec Time Memory
sample_01.txt 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB
sub1_01.txt 1 ms 256 KB
sub1_02.txt 1 ms 256 KB
sub1_03.txt 1 ms 256 KB
sub1_04.txt 1 ms 256 KB
sub1_05.txt 40 ms 17028 KB
sub1_06.txt 40 ms 17028 KB
sub1_07.txt 40 ms 17028 KB
sub1_08.txt 40 ms 17028 KB
sub1_09.txt 40 ms 17028 KB
sub1_10.txt 40 ms 17028 KB
sub1_11.txt 2 ms 512 KB
sub1_12.txt 17 ms 7300 KB
sub1_13.txt 17 ms 7044 KB
sub1_14.txt 2 ms 640 KB
sub1_15.txt 4 ms 1536 KB
sub1_16.txt 17 ms 7044 KB
sub1_17.txt 40 ms 17028 KB
sub1_18.txt 17 ms 7044 KB
sub1_19.txt 40 ms 17028 KB
sub1_20.txt 32 ms 13316 KB
sub1_21.txt 16 ms 6404 KB
sub1_22.txt 40 ms 17028 KB
sub1_23.txt 15 ms 6276 KB
sub1_24.txt 16 ms 6660 KB
sub1_25.txt 40 ms 17028 KB
sub1_26.txt 9 ms 3204 KB
sub1_27.txt 25 ms 10628 KB
sub1_28.txt 40 ms 17028 KB
sub1_29.txt 7 ms 2560 KB
sub1_30.txt 25 ms 10628 KB
sub1_31.txt 28 ms 11524 KB
sub1_32.txt 40 ms 17028 KB
sub1_33.txt 34 ms 14212 KB
sub1_34.txt 9 ms 3332 KB
sub1_35.txt 32 ms 13572 KB
sub1_36.txt 26 ms 11012 KB
sub1_37.txt 40 ms 17028 KB
sub1_38.txt 40 ms 17028 KB