/*{{{*/
#include <bits/stdc++.h>
#ifdef LOCAL
int c_;
#define cout (c_?cerr:cout)
#define debug(...) {cerr<<(c_?"":"\033[96;1m");\
++c_;__VA_ARGS__;--c_;cerr<<(c_?"":"\033[0m");}
#else
#define debug(...) {}
#endif
#define st first
#define nd second
#define all(...) begin(__VA_ARGS__), end(__VA_ARGS__)
#define dump(...) debug(print(#__VA_ARGS__" =", __VA_ARGS__))
#define dump_range(...) debug(cerr<<#__VA_ARGS__": ";print_range(__VA_ARGS__);)
using namespace std;
template< typename t >
using V = vector< t >;
using ll = long long;
using ld = long double;
void print(){cout<<'\n';}
template< typename t, typename... v >
void print(const t& a, const v&... b)
{cout<<a<<(sizeof...(b)?" ":"");print(b...);}
template< typename t >
void print_range(t a, const t& b)
{while (a!=b) cout<<(*a++)<<' ';cout<<'\n';}
/*}}}*/
constexpr ll stala = 1e16;
int main()
{
dump(stala);
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n; ll res = 0, p = 0;
int alw = 0;
cin >> n;
while (n--)
{
ll v; cin >> v;
res += alw;
ll lo = v, hi = v;
while (p >= hi)
{
++res,
hi *= 10, lo *= 10;
hi += 9;
}
if (lo > p)
p = lo;
else
p = p + 1;
dump(p);
if (p >= stala)
{
++alw; p /= 10;
}
}
print(res);
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | /*{{{*/ #include <bits/stdc++.h> #ifdef LOCAL int c_; #define cout (c_?cerr:cout) #define debug(...) {cerr<<(c_?"":"\033[96;1m");\ ++c_;__VA_ARGS__;--c_;cerr<<(c_?"":"\033[0m");} #else #define debug(...) {} #endif #define st first #define nd second #define all(...) begin(__VA_ARGS__), end(__VA_ARGS__) #define dump(...) debug(print(#__VA_ARGS__" =", __VA_ARGS__)) #define dump_range(...) debug(cerr<<#__VA_ARGS__": ";print_range(__VA_ARGS__);) using namespace std; template< typename t > using V = vector< t >; using ll = long long; using ld = long double; void print(){cout<<'\n';} template< typename t, typename... v > void print(const t& a, const v&... b) {cout<<a<<(sizeof...(b)?" ":"");print(b...);} template< typename t > void print_range(t a, const t& b) {while (a!=b) cout<<(*a++)<<' ';cout<<'\n';} /*}}}*/ constexpr ll stala = 1e16; int main() { dump(stala); ios::sync_with_stdio(false); cin.tie(nullptr); int n; ll res = 0, p = 0; int alw = 0; cin >> n; while (n--) { ll v; cin >> v; res += alw; ll lo = v, hi = v; while (p >= hi) { ++res, hi *= 10, lo *= 10; hi += 9; } if (lo > p) p = lo; else p = p + 1; dump(p); if (p >= stala) { ++alw; p /= 10; } } print(res); } |
English