26112023-01-17 23:26:35kohumarkSzivárványszámokcpp11Time limit exceeded 9/45400ms4476 KiB
#include <iostream>
#include <cmath>
using namespace std;

int count_numbers(int x) {
    int count = 0;
    for (int i = 0; i < x; i++) {
        int n = i; int ten=0;
        bool decreasing = false;
        bool increasing = true;
        int prev_digit = n % 10;
        n /= 10;
        while (n > 0) {
            int digit = n % 10;
			if (prev_digit > digit) {
				decreasing = true;
				increasing = false;
			}
			if (decreasing && prev_digit < digit) {
                decreasing = false;
                break;
            }
            prev_digit = digit;
            n /= 10;
            ten++;
        }
        if (decreasing||increasing) {
            count++;
        }
    }
    return count;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x; cin >> x;
    cout << count_numbers(x);
    return 0;
}


SubtaskSumTestVerdictTimeMemory
base9/45
1Accepted0/03ms1896 KiB
2Time limit exceeded0/0400ms2072 KiB
3Time limit exceeded0/0356ms2304 KiB
4Accepted1/12ms2556 KiB
5Accepted1/12ms2760 KiB
6Accepted1/12ms2992 KiB
7Accepted1/12ms3040 KiB
8Accepted1/12ms3012 KiB
9Accepted1/13ms3392 KiB
10Accepted1/13ms3380 KiB
11Accepted1/14ms3444 KiB
12Accepted1/14ms3644 KiB
13Time limit exceeded0/2351ms2816 KiB
14Time limit exceeded0/2360ms3760 KiB
15Time limit exceeded0/2356ms3772 KiB
16Time limit exceeded0/2368ms3764 KiB
17Time limit exceeded0/1365ms2884 KiB
18Time limit exceeded0/2361ms3892 KiB
19Time limit exceeded0/2377ms3868 KiB
20Time limit exceeded0/2349ms3144 KiB
21Time limit exceeded0/3372ms3968 KiB
22Time limit exceeded0/2354ms3964 KiB
23Time limit exceeded0/2358ms3992 KiB
24Time limit exceeded0/2344ms4120 KiB
25Time limit exceeded0/2368ms4164 KiB
26Time limit exceeded0/2361ms4276 KiB
27Time limit exceeded0/2365ms4396 KiB
28Time limit exceeded0/2344ms4476 KiB
29Time limit exceeded0/2368ms3864 KiB
30Time limit exceeded0/2398ms3800 KiB