QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#640571 | #6257. Efficient Exchange | BaBamBa# | WA | 0ms | 3776kb | C++17 | 900b | 2024-10-14 14:24:20 | 2024-10-14 14:24:20 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
string s;
cin >> s;
ll ans = 0, up = 0;
reverse(s.begin(), s.end());
s += '0';
for (int i = 0; i < s.length() - 1; i++)
{
if (s[i] - '0' + up < 5)
{
ans += s[i] - '0' + up;
up = 0;
}
else if (s[i] - '0' + up == 5)
{
if (s[i + 1] > '5')
{
ans += 10 - s[i] + '0' - up;
up = 1;
}
else
{
ans += s[i] - '0' + up;
up = 0;
}
}
else
{
ans += 10 - s[i] + '0' - up;
up = 1;
}
}
ans += up;
cout << ans << "\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3776kb
input:
83
output:
6
result:
ok single line: '6'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3616kb
input:
13
output:
4
result:
ok single line: '4'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3620kb
input:
0
output:
0
result:
ok single line: '0'
Test #4:
score: 0
Accepted
time: 0ms
memory: 3584kb
input:
12345678987654321
output:
42
result:
ok single line: '42'
Test #5:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
1
output:
1
result:
ok single line: '1'
Test #6:
score: -100
Wrong Answer
time: 0ms
memory: 3592kb
input:
108894478469214466804158556038509473912228070531930682335592810379690071992846446138400855834536144291684432969861435324866089578025171848195442401602361161260026599515983657327709498488895075795438278518721851530339458103065105649832422088699047412786278455363479689485262210227415931822805287251225...
output:
1972
result:
wrong answer 1st lines differ - expected: '1971', found: '1972'