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
#include <iostream> //2018 runda 2[B]
#include <string>
 using namespace std;
int main() {
  int nmax=200001;
  long i;
  long long N,m,c,delC,wyn;
  long long Ce[nmax],Ma[nmax];
  cin >> N;
  wyn=0; 
  for (i=1; i<=N; ++i) {
    cin >> m;  c=10;
    while(m<1000000000){
      m*=10;  c-=1;
    }
    Ce[i]=c;  Ma[i]=m;
  }
  for (i=2; i<=N; ++i) {
    if (Ce[i] <= Ce[i-1]) {
      delC=Ce[i-1]-Ce[i]; Ce[i]=Ce[i-1]; wyn+=delC;
      if (Ma[i]<= Ma[i-1]) {Ce[i]+=1; wyn+=1;}
    } 
  }
  cout << wyn << endl;
}