QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#118156#6626. Real Mountainshos_lyric#10 2027ms26924kbC++143.4kb2023-07-03 09:35:592024-05-31 18:49:18

Judging History

你现在查看的是最新测评结果

  • [2024-05-31 18:49:18]
  • 评测
  • 测评结果:10
  • 用时:2027ms
  • 内存:26924kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-03 09:35:59]
  • 提交

answer

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> ostream &operator<<(ostream &os, const vector<T> &as) { const int sz = as.size(); os << "["; for (int i = 0; i < sz; ++i) { if (i >= 256) { os << ", ..."; break; } if (i > 0) { os << ", "; } os << as[i]; } return os << "]"; }
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }


vector<int> uf;
int root(int u) {
  return (uf[u] < 0) ? u : (uf[u] = root(uf[u]));
}
bool connect(int u, int v) {
  u = root(u);
  v = root(v);
  if (u == v) return false;
  if (uf[u] > uf[v]) swap(u, v);
  uf[u] += uf[v];
  uf[v] = u;
  return true;
}


constexpr int MO = 1'000'003;
constexpr Int INF = 1001001001001001001LL;

int N;
vector<Int> A;

int main() {
  for (; ~scanf("%d", &N); ) {
    A.assign(N + 2, INF);
    for (int i = 1; i <= N; ++i) {
      scanf("%lld", &A[i]);
    }
    
    // strict
    vector<int> prv(N + 2, 0), nxt(N + 2, N + 1);
    
    Int ans = 0;
    auto as = A;
    for (; ; ) {
// cerr<<as<<" "<<ans<<endl;
      for (int i = 1; i <= N; ++i) {
        int &j = prv[i] = i - 1;
        for (; as[j] <= as[i]; j = prv[j]) {}
      }
      for (int i = N; i >= 1; --i) {
        int &j = nxt[i] = i + 1;
        for (; as[j] <= as[i]; j = nxt[j]) {}
      }
      Int mn = INF;
      for (int i = 1; i <= N; ++i) if (1 <= prv[i] && nxt[i] <= N) {
        chmin(mn, as[i]);
      }
      if (mn >= INF) {
        break;
      }
      int lm = N + 1, rm = 0;
      int cnt = 0;
      for (int i = 1; i <= N; ++i) if (1 <= prv[i] && nxt[i] <= N) {
        if (mn == as[i]) {
          chmin(lm, i);
          chmax(rm, i);
          ++cnt;
        }
      }
      
      auto calc = [&](int l, int r) -> Int {
        Int ret = INF;
        for (int i = l; i <= r; ++i) if (mn < as[i]) {
          chmin(ret, as[i]);
        }
        return ret;
      };
      const Int costLL = calc(1, lm - 1);
      const Int costLR = calc(lm + 1, N);
      const Int costRL = calc(1, rm - 1);
      const Int costRR = calc(rm + 1, N);
      if (cnt == 1) {
        ans += costLL + mn + costLR;
      } else {
        ans += min((costLL + mn + costLR) + ((mn+1) + mn + costRR),
                   (costRL + mn + costRR) + (costLL + mn + (mn+1)));
        ans += (cnt - 2) * ((mn+1) + mn + (mn+1));
      }
      ans %= MO;
      
      for (int i = 1; i <= N; ++i) if (1 <= prv[i] && nxt[i] <= N) {
        if (mn == as[i]) {
          as[i] += 1;
        }
      }
    }
    
    printf("%lld\n", ans);
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 3
Accepted

Test #1:

score: 3
Accepted
time: 0ms
memory: 3760kb

input:

3
29 9 9

output:

0

result:

ok 1 number(s): "0"

Test #2:

score: 0
Accepted
time: 1ms
memory: 4080kb

input:

3
62 20 71

output:

7287

result:

ok 1 number(s): "7287"

Test #3:

score: 0
Accepted
time: 1ms
memory: 3764kb

input:

10
72 33 22 22 13 49 53 57 72 85

output:

40403

result:

ok 1 number(s): "40403"

Test #4:

score: 0
Accepted
time: 4ms
memory: 4192kb

input:

5000
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 97 97 97 97 9...

output:

481053

result:

ok 1 number(s): "481053"

Test #5:

score: 0
Accepted
time: 1ms
memory: 3964kb

input:

5000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

0

result:

ok 1 number(s): "0"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3916kb

input:

5000
2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2...

output:

12595

result:

ok 1 number(s): "12595"

Test #7:

score: 0
Accepted
time: 1ms
memory: 3924kb

input:

5000
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100...

output:

299

result:

ok 1 number(s): "299"

Test #8:

score: 0
Accepted
time: 2ms
memory: 4164kb

input:

5000
100 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

224232

result:

ok 1 number(s): "224232"

Test #9:

score: 0
Accepted
time: 1ms
memory: 3876kb

input:

5000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4...

output:

0

result:

ok 1 number(s): "0"

Test #10:

score: 0
Accepted
time: 1ms
memory: 3956kb

input:

5000
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 9...

output:

0

result:

ok 1 number(s): "0"

Test #11:

score: 0
Accepted
time: 4ms
memory: 3876kb

input:

5000
100 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4...

output:

499735

result:

ok 1 number(s): "499735"

Test #12:

score: 0
Accepted
time: 2ms
memory: 3904kb

input:

5000
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 9...

output:

461407

result:

ok 1 number(s): "461407"

Subtask #2:

score: 3
Accepted

Dependency #1:

100%
Accepted

Test #13:

score: 3
Accepted
time: 10ms
memory: 3944kb

input:

5000
37 39 93 78 85 71 59 21 57 96 61 59 23 16 57 90 13 59 85 70 62 67 78 97 16 60 8 48 28 53 4 24 1 97 97 98 57 87 96 91 74 54 100 76 86 86 46 39 100 57 70 76 73 55 84 93 64 6 84 39 75 94 30 15 3 31 11 34 27 10 6 81 30 76 60 9 4 47 1 88 17 71 61 30 19 10 4 57 79 37 22 74 84 8 91 58 15 45 7 98 32 46...

output:

216624

result:

ok 1 number(s): "216624"

Test #14:

score: 0
Accepted
time: 0ms
memory: 3760kb

input:

29
29 62 90 18 57 29 75 67 93 45 53 45 30 77 3 52 16 31 56 37 47 52 3 23 61 66 50 39 30

output:

110566

result:

ok 1 number(s): "110566"

Test #15:

score: 0
Accepted
time: 0ms
memory: 3760kb

input:

85
11 35 37 67 43 49 100 8 72 74 42 71 14 30 69 35 42 14 67 59 48 84 15 12 64 48 34 62 78 52 95 99 58 49 63 28 84 35 17 69 97 45 40 2 52 43 56 76 82 26 4 88 59 72 99 29 62 17 42 89 25 59 48 36 31 63 3 85 16 89 41 23 24 60 79 29 32 72 21 82 64 54 47 85 95

output:

729618

result:

ok 1 number(s): "729618"

Test #16:

score: 0
Accepted
time: 10ms
memory: 3904kb

input:

5000
13 76 46 15 50 98 93 77 31 43 84 90 6 24 14 37 73 29 43 9 4 8 14 31 91 97 72 23 73 68 70 51 78 2 19 10 38 11 16 19 64 97 47 43 65 28 88 63 50 49 23 28 37 20 68 100 21 65 37 64 96 38 40 44 100 11 62 1 16 8 57 44 87 3 86 4 73 96 56 16 77 32 52 98 27 14 7 85 28 97 19 24 5 3 26 41 56 91 25 63 55 69...

output:

959697

result:

ok 1 number(s): "959697"

Test #17:

score: 0
Accepted
time: 10ms
memory: 3904kb

input:

5000
85 23 93 33 88 25 22 89 72 56 41 51 15 91 3 20 50 67 25 64 51 22 5 60 34 88 51 62 65 1 48 73 91 65 19 2 8 33 75 12 72 87 62 89 76 45 77 23 32 82 97 76 52 3 72 66 38 40 82 60 89 21 5 70 69 58 77 81 17 70 100 61 72 92 19 74 13 13 7 8 22 79 26 74 85 46 35 42 78 74 85 7 94 34 17 42 40 40 91 46 78 9...

output:

136364

result:

ok 1 number(s): "136364"

Test #18:

score: 0
Accepted
time: 10ms
memory: 4196kb

input:

5000
57 6 44 49 8 49 13 57 78 49 39 20 52 16 8 39 46 96 23 32 21 26 50 60 41 23 49 73 87 46 34 1 36 96 75 81 64 70 83 55 88 6 45 17 8 27 11 15 46 73 29 29 6 82 96 82 96 39 27 14 49 55 21 69 13 43 60 63 38 4 56 22 84 37 38 10 32 83 46 56 70 11 78 55 10 3 92 18 34 68 12 37 62 13 63 75 82 96 93 45 12 3...

output:

171486

result:

ok 1 number(s): "171486"

Test #19:

score: 0
Accepted
time: 6ms
memory: 3968kb

input:

5000
37 53 87 68 55 84 34 69 19 67 99 81 62 75 81 30 31 34 4 91 68 36 33 77 80 11 28 13 66 76 7 26 40 63 62 77 30 95 45 48 87 92 60 62 12 51 4 71 32 6 7 77 24 49 3 48 5 18 72 10 37 46 86 92 82 78 75 39 47 70 3 39 69 29 63 76 76 96 1 44 23 54 47 31 67 35 20 71 84 54 74 24 51 57 54 85 74 48 51 21 39 5...

output:

276173

result:

ok 1 number(s): "276173"

Test #20:

score: 0
Accepted
time: 4ms
memory: 3904kb

input:

5000
96 9 3 8 5 1 9 1 7 6 1 9 3 6 7 10 3 9 5 10 2 7 8 7 6 10 8 8 8 3 4 4 1 7 7 8 7 7 6 1 4 4 10 6 6 6 6 9 10 7 10 6 3 5 4 3 4 6 4 9 5 4 10 5 3 1 1 4 7 10 6 1 10 6 10 9 4 7 1 8 7 1 1 10 9 10 4 7 9 7 2 4 4 8 1 8 5 5 7 8 2 6 7 7 9 7 5 6 6 6 3 9 7 4 4 8 2 5 2 8 6 7 10 3 1 7 1 7 2 6 10 8 7 3 5 3 4 10 8 2...

output:

190251

result:

ok 1 number(s): "190251"

Test #21:

score: 0
Accepted
time: 5ms
memory: 3900kb

input:

5000
98 6 6 5 10 8 3 7 1 3 4 10 6 4 4 7 3 9 3 9 4 8 4 1 1 7 2 3 3 8 10 1 8 2 9 10 8 1 6 9 4 7 7 3 5 8 8 3 10 9 3 8 7 10 8 10 1 5 7 4 6 8 10 4 10 1 2 1 6 8 7 4 7 3 6 4 3 6 6 6 7 2 2 8 7 4 7 5 8 7 9 4 5 3 6 1 6 1 5 3 5 9 5 2 5 5 9 7 4 3 7 6 1 8 2 3 9 8 6 3 10 9 7 7 3 2 2 10 5 5 8 6 8 6 8 7 8 9 8 10 1 ...

output:

491746

result:

ok 1 number(s): "491746"

Test #22:

score: 0
Accepted
time: 2ms
memory: 4208kb

input:

5000
100 3 3 3 8 5 2 9 2 6 1 1 5 1 3 10 10 7 5 4 1 2 5 10 4 8 1 2 5 1 8 3 1 5 9 2 8 3 5 2 2 7 2 9 6 5 7 3 2 2 7 6 2 3 2 6 8 10 2 10 9 1 5 10 9 8 7 1 7 10 10 1 2 2 9 4 3 3 7 8 2 9 6 4 5 6 5 2 8 4 5 7 4 4 7 2 10 10 1 6 8 5 10 5 10 3 1 8 8 8 6 3 9 7 8 4 4 10 5 1 7 4 3 7 3 8 8 9 4 3 6 10 9 3 1 1 7 8 3 5...

output:

47458

result:

ok 1 number(s): "47458"

Test #23:

score: 0
Accepted
time: 2ms
memory: 3912kb

input:

5000
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 97 97 97 97 97 97 97 97 97 97 97 97 ...

output:

410269

result:

ok 1 number(s): "410269"

Test #24:

score: 0
Accepted
time: 4ms
memory: 3904kb

input:

5000
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 9...

output:

89583

result:

ok 1 number(s): "89583"

Test #25:

score: 0
Accepted
time: 4ms
memory: 3964kb

input:

5000
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 99 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 98 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 97 96 96 96 96...

output:

403710

result:

ok 1 number(s): "403710"

Test #26:

score: 0
Accepted
time: 5ms
memory: 3912kb

input:

5000
1 1 51 1 1 1 65 1 1 21 1 1 20 1 1 1 13 1 1 1 1 2 2 2 68 2 2 2 2 2 2 2 2 2 2 2 2 2 2 8 2 43 2 2 2 2 2 2 3 3 60 3 3 3 3 63 16 3 3 3 50 59 3 3 16 75 3 6 3 3 3 3 4 10 4 85 4 4 4 46 4 70 43 4 4 4 4 4 4 4 4 4 61 4 4 4 4 5 5 5 5 5 5 5 5 5 5 57 5 5 5 8 5 5 5 5 5 5 5 5 3 6 6 6 49 6 25 6 6 6 21 6 6 6 6 6...

output:

287987

result:

ok 1 number(s): "287987"

Test #27:

score: 0
Accepted
time: 5ms
memory: 4164kb

input:

5000
1 1 3 1 1 1 1 1 61 1 1 1 1 12 1 1 24 96 1 60 1 1 1 37 1 1 1 1 2 2 2 2 42 2 2 2 2 2 2 2 2 46 69 2 2 39 3 3 3 3 3 1 3 27 3 3 3 3 3 3 3 3 3 3 43 3 3 3 3 3 3 29 3 3 57 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 12 75 4 24 4 4 89 4 4 4 24 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 37 5 5 5 5 5 5 5 41 5 5 6 6 6 6 6 ...

output:

482347

result:

ok 1 number(s): "482347"

Test #28:

score: 0
Accepted
time: 5ms
memory: 3900kb

input:

5000
1 1 85 51 96 1 1 82 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 13 2 48 2 2 2 2 2 92 8 2 2 78 2 3 69 3 20 3 3 3 3 3 3 3 3 3 3 3 70 3 3 3 62 3 26 3 4 4 33 4 4 4 4 4 4 26 4 84 4 85 4 4 4 4 32 5 100 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 75 5 5 5 5 5 89 5 5 5 22 5 5 5 5 6 6 6 6 6 6 60 19 6 6 55 6 100 6 6 6 6 6...

output:

714189

result:

ok 1 number(s): "714189"

Test #29:

score: 0
Accepted
time: 0ms
memory: 3852kb

input:

3
100 1 100

output:

24750

result:

ok 1 number(s): "24750"

Test #30:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

3
1 2 3

output:

0

result:

ok 1 number(s): "0"

Test #31:

score: 0
Accepted
time: 0ms
memory: 3796kb

input:

3
3 2 1

output:

0

result:

ok 1 number(s): "0"

Test #32:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

3
100 100 100

output:

0

result:

ok 1 number(s): "0"

Test #33:

score: 0
Accepted
time: 0ms
memory: 3828kb

input:

5
100 1 2 1 98

output:

57420

result:

ok 1 number(s): "57420"

Subtask #3:

score: 0
Time Limit Exceeded

Dependency #2:

100%
Accepted

Test #34:

score: 0
Time Limit Exceeded

input:

5000
407609 427494 229544 174201 237923 974106 83376 278833 559089 156614 683522 171512 683333 140787 568442 381473 161683 880608 849863 503926 181414 366081 829869 14514 752859 488252 473987 428487 879011 543082 18678 52954 281414 582364 737092 67586 693723 150612 421762 168780 815185 837639 336407...

output:


result:


Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 4
Accepted

Dependency #2:

100%
Accepted

Test #62:

score: 4
Accepted
time: 2021ms
memory: 26580kb

input:

1000000
62 1 73 90 31 17 19 13 36 87 67 10 97 21 84 61 55 9 32 55 63 32 72 52 5 76 44 40 90 40 93 77 74 83 30 64 59 36 50 72 27 24 32 10 54 91 54 35 2 23 39 33 82 60 9 22 52 59 63 71 15 18 52 62 21 81 35 40 57 85 52 60 22 51 37 43 67 93 79 50 77 94 61 31 44 73 72 36 26 86 26 23 27 93 74 52 11 93 90 ...

output:

911708

result:

ok 1 number(s): "911708"

Test #63:

score: 0
Accepted
time: 2022ms
memory: 26924kb

input:

1000000
38 57 20 16 70 40 44 25 80 4 27 66 3 92 65 51 40 58 10 3 15 55 63 77 48 56 23 79 78 69 70 7 71 46 34 60 29 61 17 66 27 6 47 55 66 15 42 99 88 56 21 81 89 40 17 83 61 38 8 67 7 13 17 84 98 24 46 17 58 51 95 70 7 48 62 9 7 14 26 42 35 38 35 16 97 5 5 90 77 68 88 6 15 24 57 54 3 38 44 9 14 8 45...

output:

412956

result:

ok 1 number(s): "412956"

Test #64:

score: 0
Accepted
time: 2023ms
memory: 26664kb

input:

1000000
10 90 77 45 50 63 86 89 55 51 50 97 78 92 22 99 96 21 73 41 52 96 91 15 19 93 82 54 23 88 37 26 48 51 52 73 18 74 29 98 25 53 6 27 40 62 77 23 42 48 63 28 64 9 1 90 30 5 66 91 29 44 34 29 87 12 96 88 47 49 46 29 64 79 84 3 71 67 81 74 82 7 22 83 18 9 12 29 18 24 94 44 37 19 93 36 36 92 66 70...

output:

837967

result:

ok 1 number(s): "837967"

Test #65:

score: 0
Accepted
time: 2015ms
memory: 26788kb

input:

1000000
90 45 27 67 85 90 2 5 95 69 10 49 88 62 7 78 77 71 51 96 4 10 82 31 62 85 61 5 6 10 11 59 61 15 43 69 88 3 92 87 20 39 25 64 51 74 65 79 20 77 49 77 67 89 1 56 43 84 14 87 18 35 95 40 52 47 11 60 56 11 97 43 49 67 17 69 11 80 28 66 32 50 91 55 75 37 44 83 76 9 60 35 26 58 84 38 19 41 32 50 5...

output:

581326

result:

ok 1 number(s): "581326"

Test #66:

score: 0
Accepted
time: 2027ms
memory: 26844kb

input:

1000000
62 20 71 79 5 22 2 61 2 65 8 31 20 80 12 100 73 88 48 68 73 13 27 35 73 23 63 4 32 67 96 79 97 45 7 48 36 41 100 34 40 58 92 92 88 60 8 71 30 72 72 30 25 67 20 68 5 75 55 42 77 69 7 51 100 40 99 46 77 45 49 7 58 9 40 18 30 58 71 15 79 73 43 36 89 98 1 50 24 4 74 61 94 29 34 71 62 88 30 61 94...

output:

414210

result:

ok 1 number(s): "414210"

Test #67:

score: 0
Accepted
time: 1ms
memory: 4084kb

input:

344
82 13 48 35 40 17 86 8 25 13 100 63 2 39 78 32 29 14 63 12 71 68 42 19 7 33 37 91 93 98 17 50 64 96 55 28 44 98 62 98 69 55 19 32 47 65 52 45 28 74 21 41 40 63 2 10 72 88 47 84 18 34 22 39 71 14 20 93 30 43 100 48 91 91 11 49 21 30 31 36 99 2 21 86 87 26 30 19 98 27 25 52 21 89 47 98 44 23 26 72...

output:

388100

result:

ok 1 number(s): "388100"

Test #68:

score: 0
Accepted
time: 1ms
memory: 3832kb

input:

338
32 39 60 38 62 15 49 53 95 46 34 74 78 3 76 69 100 42 83 55 16 48 56 97 48 15 13 78 25 59 41 48 75 26 33 15 50 20 32 73 38 40 100 79 36 22 7 19 40 7 63 76 97 64 70 54 4 70 55 75 13 40 87 10 95 93 41 60 12 30 14 42 92 58 65 76 73 29 77 82 10 84 74 50 89 40 23 31 86 18 7 92 19 37 84 77 94 44 10 5 ...

output:

60017

result:

ok 1 number(s): "60017"

Test #69:

score: 0
Accepted
time: 821ms
memory: 26796kb

input:

1000000
94 9 9 10 5 7 4 1 3 5 7 7 10 6 10 3 5 3 2 7 9 8 7 7 3 3 7 6 4 5 9 6 5 1 1 3 4 4 2 3 4 3 1 4 3 8 8 5 6 1 9 3 7 3 3 9 6 3 5 10 4 9 6 10 7 10 10 9 3 4 4 9 6 8 6 10 4 9 8 6 2 8 1 7 2 1 1 5 5 5 6 8 9 8 7 7 6 3 7 5 8 4 4 6 7 3 6 1 9 5 5 9 8 4 8 4 2 4 9 9 1 2 9 7 10 1 7 5 4 9 5 9 5 5 9 8 10 2 1 6 3...

output:

399462

result:

ok 1 number(s): "399462"

Test #70:

score: 0
Accepted
time: 807ms
memory: 26804kb

input:

1000000
92 8 3 8 4 4 1 9 8 2 2 3 9 5 3 2 7 1 4 8 9 10 8 4 2 4 9 5 8 5 3 6 8 9 8 3 10 9 10 7 3 9 10 9 4 4 1 1 2 1 9 7 2 1 3 5 5 2 10 6 9 10 7 6 4 3 10 2 4 6 10 9 7 6 6 6 7 6 1 8 8 2 7 9 1 9 9 8 1 2 2 1 8 7 8 3 10 2 1 10 3 10 3 1 3 9 5 2 3 10 8 10 6 6 4 3 7 3 8 1 7 7 3 3 10 2 6 9 6 5 3 8 7 2 3 1 7 7 1...

output:

411420

result:

ok 1 number(s): "411420"

Test #71:

score: 0
Accepted
time: 794ms
memory: 26676kb

input:

1000000
97 3 7 2 10 4 1 9 9 7 6 1 4 10 7 4 6 8 2 6 6 6 4 8 7 5 2 6 10 4 8 9 5 5 4 2 6 9 4 9 9 9 9 3 5 6 5 7 2 5 9 4 10 3 1 7 1 1 10 1 2 4 6 1 8 2 9 9 1 10 7 7 4 7 4 7 1 3 8 7 9 9 3 4 5 5 6 5 7 1 8 5 6 2 4 9 9 7 9 3 5 7 2 2 1 5 5 5 6 9 2 8 9 1 10 9 9 3 2 7 6 10 2 6 1 10 10 9 4 7 8 3 1 2 7 6 8 9 8 5 2...

output:

404981

result:

ok 1 number(s): "404981"

Test #72:

score: 0
Accepted
time: 727ms
memory: 26924kb

input:

1000000
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 ...

output:

441999

result:

ok 1 number(s): "441999"

Test #73:

score: 0
Accepted
time: 732ms
memory: 26560kb

input:

1000000
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 ...

output:

414038

result:

ok 1 number(s): "414038"

Test #74:

score: 0
Accepted
time: 729ms
memory: 26732kb

input:

1000000
100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 100 ...

output:

990184

result:

ok 1 number(s): "990184"

Test #75:

score: 0
Accepted
time: 1118ms
memory: 26792kb

input:

1000000
1 1 1 1 1 1 1 1 20 1 95 1 75 1 1 1 1 1 1 1 1 1 1 1 1 1 76 1 66 1 1 1 1 1 1 1 1 1 1 46 1 1 1 1 1 1 1 36 1 1 1 1 1 60 83 1 1 1 1 1 4 1 1 89 43 79 1 1 1 1 36 1 12 55 1 1 1 1 1 58 1 1 1 1 41 1 1 1 1 1 49 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 94 1 1 1 1 10 1 1 1 1 69 1 1 1 1 1 1 1 80 1 1 1 1 ...

output:

597485

result:

ok 1 number(s): "597485"

Test #76:

score: 0
Accepted
time: 1103ms
memory: 26720kb

input:

1000000
1 1 1 1 1 1 37 1 1 1 1 87 1 1 1 26 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 17 1 1 1 1 1 1 1 7 81 1 1 1 1 1 1 28 1 1 1 1 1 19 1 1 1 1 1 1 1 1 1 86 42 1 1 1 1 90 1 1 1 55 1 1 54 1 1 1 1 1 1 1 1 1 50 1 50 1 1 1 1 11 1 29 1 1 1 1 1 1 1 71 1 51 1 1 1 55 1 1 1 1 1 96 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

151444

result:

ok 1 number(s): "151444"

Test #77:

score: 0
Accepted
time: 1105ms
memory: 26664kb

input:

1000000
1 1 20 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 50 53 1 1 1 1 1 1 1 1 1 1 30 1 1 1 1 1 1 1 1 1 1 38 1 1 1 1 1 17 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 87 98 1 52 1 1 1 1 1 89 1 1 1 1 1 1 53 1 38 1 1 38 1 1 1 1 1 4 1 1 1 1 89 1 1 1 1 1 1 1 1 1 73 1 39 1 12 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 44 1 1 1 1 11 1 7...

output:

199390

result:

ok 1 number(s): "199390"

Subtask #6:

score: 0
Skipped

Dependency #3:

0%

Subtask #7:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

0%