Please sign in first.
Submission #66097820
Source Code Expand
#include <bits/stdc++.h>
#include <cstdlib>
#define int ll
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int N = 5e5 + 10;
int read() {
int x = 0, f = 1;
char c = getchar();
while(c < '0' || c > '9')
f = (c == '-') ? -1 : 1, c = getchar();
while(c >= '0' && c <= '9')
x = x * 10 + c - 48, c = getchar();
return f * x;
}
signed main() {
string s;
cin >> s;
int n = s.size();
s = " " + s;
int ans = n;
int cnt = 0;
s = s + '0';
for(int i = n; i >= 1; i--) {
int now = s[i + 1];
int z;
if(s[i] >= now)
z = (s[i] - now);
else
z = ('9' - now + s[i] - '0' + 1);
// cout << z << " ";
cnt += z;
}
cout << cnt + n << "\n";
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Security 2 |
| User | hbx |
| Language | C++ 20 (gcc 12.2) |
| Score | 300 |
| Code Size | 827 Byte |
| Status | AC |
| Exec Time | 9 ms |
| Memory | 4788 KiB |
Compile Error
Main.cpp: In function ‘int main()’:
Main.cpp:22:9: warning: unused variable ‘ans’ [-Wunused-variable]
22 | int ans = n;
| ^~~
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt |
| All | 00-sample-01.txt, 00-sample-02.txt, 00-sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 01-11.txt, 01-12.txt, 01-13.txt, 01-14.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00-sample-01.txt | AC | 1 ms | 3516 KiB |
| 00-sample-02.txt | AC | 1 ms | 3444 KiB |
| 00-sample-03.txt | AC | 1 ms | 3476 KiB |
| 01-01.txt | AC | 1 ms | 3476 KiB |
| 01-02.txt | AC | 1 ms | 3400 KiB |
| 01-03.txt | AC | 1 ms | 3484 KiB |
| 01-04.txt | AC | 1 ms | 3440 KiB |
| 01-05.txt | AC | 1 ms | 3532 KiB |
| 01-06.txt | AC | 1 ms | 3472 KiB |
| 01-07.txt | AC | 1 ms | 3484 KiB |
| 01-08.txt | AC | 1 ms | 3472 KiB |
| 01-09.txt | AC | 1 ms | 3464 KiB |
| 01-10.txt | AC | 2 ms | 3664 KiB |
| 01-11.txt | AC | 9 ms | 4696 KiB |
| 01-12.txt | AC | 9 ms | 4640 KiB |
| 01-13.txt | AC | 7 ms | 4788 KiB |
| 01-14.txt | AC | 7 ms | 4616 KiB |