CSES - Putka Open 2020 – 3/5 - Results
Submission details
Task:Numerot
Sender:mango_lassi
Submission time:2020-10-17 19:37:29 +0300
Language:C++ (C++11)
Status:READY
Result:25
Feedback
groupverdictscore
#1ACCEPTED12
#2ACCEPTED13
#30
Test results
testverdicttimegroup
#1ACCEPTED0.16 s1, 2, 3details
#2ACCEPTED0.16 s2, 3details
#30.16 s3details

Code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int N = 1e7;
int dp[N + 1];
int ans[N + 1];

ll reduce(ll v) {
	ll tmp = v;
	ll mx = 0;
	while(tmp) {
		mx = max(mx, tmp % 10);
		tmp /= 10;
	}
	return v - mx;
}

void solve() {
	ll x;
	cin >> x;
	cout << ans[x] << '\n';
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	for (int v = 1; v <= N; ++v) {
		dp[v] = 1 + dp[reduce(v)];
		if (dp[v] > dp[v-1]) ans[dp[v]] = v;
	}

	int t;
	cin >> t;
	for (int ti = 0; ti < t; ++ti) solve();
}

Test details

Test 1

Group: 1, 2, 3

Verdict: ACCEPTED

input
1000
1
2
3
4
...

correct output
1
10
11
20
22
...

user output
1
10
11
20
22
...
Truncated

Test 2

Group: 2, 3

Verdict: ACCEPTED

input
1000
224995
413660
249827
2125
...

correct output
1731724
3216040
1940719
14585
532612
...

user output
1731724
3216040
1940719
14585
532612
...
Truncated

Test 3

Group: 3

Verdict:

input
1000
627887018110416188
785474884983906653
653772166720939773
784335285960673683
...

correct output
5530371754830260284
6918696171534226533
5757755627065159149
6908439780325129803
3223801064342340738
...

user output
(empty)