QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#118907#5459. Goose, goose, DUCK?hos_lyricAC ✓1100ms106424kbC++148.3kb2023-07-04 15:23:402023-07-04 15:23:41

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-04 15:23:41]
  • 评测
  • 测评结果:AC
  • 用时:1100ms
  • 内存:106424kb
  • [2023-07-04 15:23:40]
  • 提交

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 <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; }


// T: monoid representing information of an interval.
//   T()  should return the identity.
//   T(S s)  should represent a single element of the array.
//   T::push(T &l, T &r)  should push the lazy update.
//   T::pull(const T &l, const T &r)  should pull two intervals.
template <class T> struct SegmentTreeRange {
  int logN, n;
  vector<T> ts;
  SegmentTreeRange() {}
  explicit SegmentTreeRange(int n_) {
    for (logN = 0, n = 1; n < n_; ++logN, n <<= 1) {}
    ts.resize(n << 1);
  }
  template <class S> explicit SegmentTreeRange(const vector<S> &ss) {
    const int n_ = ss.size();
    for (logN = 0, n = 1; n < n_; ++logN, n <<= 1) {}
    ts.resize(n << 1);
    for (int i = 0; i < n_; ++i) at(i) = T(ss[i]);
    build();
  }
  T &at(int i) {
    return ts[n + i];
  }
  void build() {
    for (int u = n; --u; ) pull(u);
  }

  inline void push(int u) {
    ts[u].push(ts[u << 1], ts[u << 1 | 1]);
  }
  inline void pull(int u) {
    ts[u].pull(ts[u << 1], ts[u << 1 | 1]);
  }

  // Applies T::f(args...) to [a, b).
  template <class F, class... Args>
  void ch(int a, int b, F f, Args &&... args) {
    assert(0 <= a); assert(a <= b); assert(b <= n);
    if (a == b) return;
    a += n; b += n;
    for (int h = logN; h; --h) {
      const int aa = a >> h, bb = b >> h;
      if (aa == bb) {
        if ((aa << h) != a || (bb << h) != b) push(aa);
      } else {
        if ((aa << h) != a) push(aa);
        if ((bb << h) != b) push(bb);
      }
    }
    for (int aa = a, bb = b; aa < bb; aa >>= 1, bb >>= 1) {
      if (aa & 1) (ts[aa++].*f)(args...);
      if (bb & 1) (ts[--bb].*f)(args...);
    }
    for (int h = 1; h <= logN; ++h) {
      const int aa = a >> h, bb = b >> h;
      if (aa == bb) {
        if ((aa << h) != a || (bb << h) != b) pull(aa);
      } else {
        if ((aa << h) != a) pull(aa);
        if ((bb << h) != b) pull(bb);
      }
    }
  }

  // Calculates the product for [a, b).
  T get(int a, int b) {
    assert(0 <= a); assert(a <= b); assert(b <= n);
    if (a == b) return T();
    a += n; b += n;
    for (int h = logN; h; --h) {
      const int aa = a >> h, bb = b >> h;
      if (aa == bb) {
        if ((aa << h) != a || (bb << h) != b) push(aa);
      } else {
        if ((aa << h) != a) push(aa);
        if ((bb << h) != b) push(bb);
      }
    }
    T prodL, prodR, t;
    for (int aa = a, bb = b; aa < bb; aa >>= 1, bb >>= 1) {
      if (aa & 1) { t.pull(prodL, ts[aa++]); prodL = t; }
      if (bb & 1) { t.pull(ts[--bb], prodR); prodR = t; }
    }
    t.pull(prodL, prodR);
    return t;
  }

  // Calculates T::f(args...) of a monoid type for [a, b).
  //   op(-, -)  should calculate the product.
  //   e()  should return the identity.
  template <class Op, class E, class F, class... Args>
#if __cplusplus >= 201402L
  auto
#else
  decltype((std::declval<T>().*F())())
#endif
  get(int a, int b, Op op, E e, F f, Args &&... args) {
    assert(0 <= a); assert(a <= b); assert(b <= n);
    if (a == b) return e();
    a += n; b += n;
    for (int h = logN; h; --h) {
      const int aa = a >> h, bb = b >> h;
      if (aa == bb) {
        if ((aa << h) != a || (bb << h) != b) push(aa);
      } else {
        if ((aa << h) != a) push(aa);
        if ((bb << h) != b) push(bb);
      }
    }
    auto prodL = e(), prodR = e();
    for (int aa = a, bb = b; aa < bb; aa >>= 1, bb >>= 1) {
      if (aa & 1) prodL = op(prodL, (ts[aa++].*f)(args...));
      if (bb & 1) prodR = op((ts[--bb].*f)(args...), prodR);
    }
    return op(prodL, prodR);
  }

  // Find min b s.t. T::f(args...) returns true,
  // when called for the partition of [a, b) from left to right.
  //   Returns n + 1 if there is no such b.
  template <class F, class... Args>
  int findRight(int a, F f, Args &&... args) {
    assert(0 <= a); assert(a <= n);
    if ((T().*f)(args...)) return a;
    if (a == n) return n + 1;
    a += n;
    for (int h = logN; h; --h) push(a >> h);
    for (; ; a >>= 1) if (a & 1) {
      if ((ts[a].*f)(args...)) {
        for (; a < n; ) {
          push(a);
          if (!(ts[a <<= 1].*f)(args...)) ++a;
        }
        return a - n + 1;
      }
      ++a;
      if (!(a & (a - 1))) return n + 1;
    }
  }

  // Find max a s.t. T::f(args...) returns true,
  // when called for the partition of [a, b) from right to left.
  //   Returns -1 if there is no such a.
  template <class F, class... Args>
  int findLeft(int b, F f, Args &&... args) {
    assert(0 <= b); assert(b <= n);
    if ((T().*f)(args...)) return b;
    if (b == 0) return -1;
    b += n;
    for (int h = logN; h; --h) push((b - 1) >> h);
    for (; ; b >>= 1) if ((b & 1) || b == 2) {
      if ((ts[b - 1].*f)(args...)) {
        for (; b <= n; ) {
          push(b - 1);
          if (!(ts[(b <<= 1) - 1].*f)(args...)) --b;
        }
        return b - n - 1;
      }
      --b;
      if (!(b & (b - 1))) return -1;
    }
  }
};

////////////////////////////////////////////////////////////////////////////////


using Value = int;
constexpr Value INF = 1001001001;

struct NodeCountMin {
  Value mn, lz;
  int cnt;
  NodeCountMin() : mn(INF), lz(0), cnt(0) {}
  NodeCountMin(Value val) : mn(val), lz(0), cnt(1) {}
  void push(NodeCountMin &l, NodeCountMin &r) {
    if (lz) {
      l.add(lz);
      r.add(lz);
      lz = 0;
    }
  }
  void pull(const NodeCountMin &l, const NodeCountMin &r) {
    if (l.mn < r.mn) {
      mn = l.mn;
      cnt = l.cnt;
    } else if (l.mn > r.mn) {
      mn = r.mn;
      cnt = r.cnt;
    } else {
      mn = l.mn;
      cnt = l.cnt + r.cnt;
    }
  }
  void add(Value val) {
    mn += val;
    lz += val;
  }
};


int N, K;
vector<int> A;

int main() {
  for (; ~scanf("%d%d", &N, &K); ) {
    A.resize(N);
    for (int i = 0; i < N; ++i) {
      scanf("%d", &A[i]);
    }
    
    vector<pair<int, int>> ps(N);
    for (int i = 0; i < N; ++i) {
      ps[i] = make_pair(A[i], i);
    }
    sort(ps.begin(), ps.end());
    
    vector<vector<pair<pair<int, int>, int>>> ess(N + 1);
    auto add = [&](int l0, int l1, int r0, int r1) -> void {
// cerr<<"add "<<l0<<" "<<l1<<" "<<r0<<" "<<r1<<endl;
      ess[l0 + 1].emplace_back(make_pair(r0 + 1, r1 + 1), +1);
      ess[l1 + 1].emplace_back(make_pair(r0 + 1, r1 + 1), -1);
    };
    for (int i = 0, j; i < N; i = j) {
      for (j = i; j < N && ps[i].first == ps[j].first; ++j) {}
      if (j - i >= K) {
        for (int h = 0; h + K <= j - i; ++h) {
          const int kL = i + h;
          const int kR = i + h + (K - 1);
          add(
            (kL == i) ? -1 : ps[kL - 1].second,
            ps[kL].second,
            ps[kR].second,
            (kR + 1 == j) ? N : ps[kR + 1].second
          );
        }
      }
    }
    
    SegmentTreeRange<NodeCountMin> seg(vector<int>(N + 1, 0));
    Int ans = 0;
    for (int l = 0; l < N; ++l) {
      for (const auto &e : ess[l]) {
        seg.ch(e.first.first, e.first.second, &NodeCountMin::add, e.second);
      }
      const auto res = seg.get(l + 1, N + 1);
      if (res.mn == 0) {
        ans += res.cnt;
      }
    }
    printf("%lld\n", ans);
  }
  return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3692kb

input:

6 2
1 2 2 1 3 3

output:

10

result:

ok 1 number(s): "10"

Test #2:

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

input:

6 1
1 2 3 4 5 6

output:

0

result:

ok 1 number(s): "0"

Test #3:

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

input:

100 10
142826 764475 142826 986320 764475 142826 142826 986320 764475 986320 764475 764475 764475 142826 142826 986320 764475 986320 764475 764475 142826 764475 142826 764475 986320 986320 764475 142826 764475 764475 142826 764475 764475 986320 142826 142826 142826 142826 764475 986320 986320 764475...

output:

4309

result:

ok 1 number(s): "4309"

Test #4:

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

input:

1000 100
144044 144044 606320 144044 144044 653289 606320 606320 606320 144044 653289 606320 144044 606320 144044 653289 606320 653289 144044 144044 606320 606320 606320 144044 606320 653289 653289 144044 606320 606320 606320 606320 606320 606320 606320 606320 653289 606320 653289 606320 653289 6532...

output:

494331

result:

ok 1 number(s): "494331"

Test #5:

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

input:

1000 2
37158 712133 695735 352502 37158 111876 979836 322207 850 170255 712133 37158 68113 170255 269273 322207 644692 127744 575843 269273 352502 68113 166126 413274 111876 575843 704107 695735 37158 604776 127744 269273 166126 704107 850 111876 352502 979836 850 850 712133 850 979836 575843 704107...

output:

382010

result:

ok 1 number(s): "382010"

Test #6:

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

input:

1000 1
439144 11249 309118 842057 842057 938195 823723 842057 589439 914850 938195 455713 91595 938195 553566 761181 553566 70966 455713 439144 704849 11249 11249 236580 320993 933831 872377 589439 435476 558991 914850 690853 482410 690853 715546 155003 435476 155003 435476 435476 842057 236580 7096...

output:

341042

result:

ok 1 number(s): "341042"

Test #7:

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

input:

1000 1
675227 756097 647871 465683 473815 162625 396802 61313 758469 968915 283015 326083 86904 672294 145904 621859 346020 237440 669779 282692 626616 722910 999031 141389 440533 971280 807058 346648 405103 669779 463968 214284 50833 661085 826455 991362 984243 704592 426668 998421 949882 147122 72...

output:

1

result:

ok 1 number(s): "1"

Test #8:

score: 0
Accepted
time: 1100ms
memory: 106424kb

input:

1000000 1
420242 544222 171447 777913 987553 724009 569564 35971 931705 898245 672004 267555 967920 126950 627536 979230 592634 345070 437097 838283 124796 525563 988560 362647 502828 510728 538451 742569 327219 207978 943947 684879 278534 669721 356340 258535 85663 265714 956295 291196 419333 19692...

output:

0

result:

ok 1 number(s): "0"

Test #9:

score: 0
Accepted
time: 797ms
memory: 97940kb

input:

1000000 1
559660 917135 718911 137428 227265 619698 582978 634509 968207 398589 647945 907790 647945 453872 267596 39233 647945 225421 404411 559660 401213 907790 765663 401213 339252 723380 907790 619698 896672 907790 58034 686103 455430 917135 686103 225421 619698 203386 893988 438096 75622 401213...

output:

499686064890

result:

ok 1 number(s): "499686064890"

Test #10:

score: 0
Accepted
time: 870ms
memory: 97900kb

input:

1000000 20
861642 606482 953312 90817 363428 948603 487519 232986 519567 387790 428832 519567 307633 737110 521903 537123 787533 232986 5583 363428 162408 90817 179560 859355 774243 861642 776916 206258 801420 519567 801420 422101 206258 787533 390434 62305 994340 741875 801420 138248 519567 531603 ...

output:

499129896013

result:

ok 1 number(s): "499129896013"

Test #11:

score: 0
Accepted
time: 801ms
memory: 97792kb

input:

1000000 200
485566 524102 778359 799174 823706 763480 616196 623850 594064 472722 778359 759395 336774 823706 814350 623850 662712 209130 702939 493199 974047 941295 623850 472722 947166 336774 493199 371798 974047 632804 702939 724695 509242 662712 776785 411318 280490 759395 336774 89517 493199 30...

output:

498381370313

result:

ok 1 number(s): "498381370313"

Test #12:

score: 0
Accepted
time: 587ms
memory: 97288kb

input:

1000000 2000
278305 278305 348110 113854 832030 667125 113854 821689 667125 481645 305363 481645 348110 481645 278305 123360 821689 348110 481645 305363 305363 832030 123360 821689 832030 481645 113854 123360 832030 541509 278305 832030 541509 113854 481645 278305 113854 481645 305363 348110 278305 ...

output:

499905050517

result:

ok 1 number(s): "499905050517"

Test #13:

score: 0
Accepted
time: 631ms
memory: 98020kb

input:

1000000 1
20506 24350 30587 37027 42391 66414 97104 110890 139464 147153 151865 154652 163381 181574 232570 237490 262035 270050 287512 300416 308447 310125 310983 312781 317123 318837 328920 330480 344807 346415 348094 350611 356439 366128 374463 383635 386897 408221 415742 416461 417999 419807 425...

output:

499801321042

result:

ok 1 number(s): "499801321042"

Test #14:

score: 0
Accepted
time: 607ms
memory: 98036kb

input:

1000000 3
11023 31773 32161 38871 41021 44852 48136 50602 53388 101255 102564 106529 107369 122558 127492 129008 139504 168813 175401 197384 227294 235164 240779 260845 274861 280036 294860 328235 353725 355819 364809 368636 371245 380336 385635 387362 387463 397455 399364 401758 407996 424116 42811...

output:

499800994499

result:

ok 1 number(s): "499800994499"

Test #15:

score: 0
Accepted
time: 638ms
memory: 98016kb

input:

1000000 20
3503 16481 16795 23406 31913 41872 51334 54530 54659 58868 61041 88488 93579 109541 110340 128839 131239 134456 158540 178156 181454 198922 200083 203463 220228 224053 260400 262942 280472 285105 287261 318193 338271 345198 355790 359916 372574 374790 380392 391766 416424 418976 424552 42...

output:

499797927548

result:

ok 1 number(s): "499797927548"

Test #16:

score: 0
Accepted
time: 632ms
memory: 97672kb

input:

1000000 100
26705 33485 50901 54941 68943 81029 85286 113183 123732 125867 126194 135433 178979 180530 192244 193156 208961 212468 217679 227986 240063 252514 254933 257638 257813 261582 271371 292677 298888 319760 321433 327241 345967 347806 360472 369382 385741 390248 396342 405013 405299 411923 4...

output:

499785153218

result:

ok 1 number(s): "499785153218"

Test #17:

score: 0
Accepted
time: 645ms
memory: 95108kb

input:

1000000 1000
54734 56859 60900 69121 73309 75054 98086 124241 128326 130579 133938 138638 170907 174090 209593 210626 227131 240148 285324 294171 294911 306676 310066 315911 316415 323391 325543 335382 338701 356893 357975 361369 375642 393131 412064 424646 429594 433991 441381 448701 450511 478719 ...

output:

499711049085

result:

ok 1 number(s): "499711049085"

Test #18:

score: 0
Accepted
time: 265ms
memory: 66864kb

input:

1000000 10000
15780 26236 27684 29851 30391 70638 74718 105424 106626 112856 121360 136256 143306 144423 160215 172628 178833 187008 187580 193012 204251 249462 268531 307132 312751 317920 334377 334794 338564 346157 346869 361652 385944 418212 419616 431221 452685 453777 457638 457725 499400 508745...

output:

500000494950

result:

ok 1 number(s): "500000494950"

Test #19:

score: 0
Accepted
time: 697ms
memory: 97968kb

input:

1000000 3
13192 25254 37301 53898 55107 56589 60875 62479 90808 108918 112707 135312 138180 140042 144199 146700 148639 159639 161015 182707 203339 205293 217104 217993 221972 233487 256690 279730 303295 315509 323466 324495 343702 348772 362594 552837 376486 381055 388704 399808 401931 422683 43256...

output:

499724407843

result:

ok 1 number(s): "499724407843"

Test #20:

score: 0
Accepted
time: 677ms
memory: 97936kb

input:

1000000 20
31594 44498 46841 50016 54025 62603 67202 69488 70166 115334 144272 148075 153366 157675 165752 175136 182730 201633 206707 212924 226032 245422 258994 270652 317043 338717 338753 339996 345085 346180 359946 367730 371425 376731 407733 409245 410195 416008 431461 439720 442584 444716 4468...

output:

499596476425

result:

ok 1 number(s): "499596476425"

Test #21:

score: 0
Accepted
time: 724ms
memory: 97564kb

input:

1000000 100
57157 111627 122547 135685 140722 142818 153374 209026 223146 239026 252837 256776 281064 289700 290219 292233 294024 349159 355923 361093 362183 378753 381072 389411 391472 391617 396151 397557 398169 428876 432451 435010 449056 449146 451048 460835 462298 474684 482179 482770 488686 49...

output:

499391962641

result:

ok 1 number(s): "499391962641"

Test #22:

score: 0
Accepted
time: 723ms
memory: 95040kb

input:

1000000 1000
31493 41881 47733 61011 71910 80336 95923 110457 110595 120368 127883 129274 173259 176814 195869 210362 221085 239440 255462 257568 259584 285984 290476 297671 313610 334878 338145 362300 365380 367825 380147 392530 394324 395227 406251 406263 418868 432138 437741 438162 486778 512830 ...

output:

498783493376

result:

ok 1 number(s): "498783493376"

Test #23:

score: 0
Accepted
time: 247ms
memory: 66704kb

input:

1000000 10000
42038 50384 66576 86923 87920 89011 112787 113849 124259 126873 129621 137006 139874 157994 325776 166583 186258 198164 209632 210915 211671 214969 216668 217801 237103 239515 249705 268737 281178 294292 319964 325776 340804 352085 354292 363407 388690 392733 393593 397954 405187 41300...

output:

500000487674

result:

ok 1 number(s): "500000487674"

Test #24:

score: 0
Accepted
time: 873ms
memory: 98012kb

input:

1000000 20
8297 10253 11655 35181 469963 40980 44610 45480 45968 144412 349288 110821 793614 35181 141187 44610 144412 147994 162380 163126 8297 715077 223055 227282 239159 255415 256199 270255 793614 393755 286243 296085 307696 864863 322214 326864 328862 594408 673065 386853 393755 937498 412435 4...

output:

498372290400

result:

ok 1 number(s): "498372290400"

Test #25:

score: 0
Accepted
time: 859ms
memory: 97704kb

input:

1000000 100
486435 23761 24235 33864 40684 53396 57584 295737 896419 77583 583583 548385 493160 791063 144501 486435 170285 174686 187914 77583 199976 209866 221143 222079 231963 975385 245272 246644 252021 295737 296906 313568 324144 334442 343938 349704 368668 421176 805941 919799 382762 812603 42...

output:

496980423237

result:

ok 1 number(s): "496980423237"

Test #26:

score: 0
Accepted
time: 748ms
memory: 94988kb

input:

1000000 1000
2145 68136 16607 409458 22354 61633 68136 68812 69932 84624 202591 96813 99616 101201 123924 709687 140217 146803 149628 154171 173873 181288 202591 203691 433640 181288 260177 260255 262688 417949 285610 296625 316727 329114 332321 781226 790225 950078 409458 399598 272557 412138 41794...

output:

494633760441

result:

ok 1 number(s): "494633760441"

Test #27:

score: 0
Accepted
time: 271ms
memory: 66864kb

input:

1000000 10000
17351 65877 101842 108439 130529 131763 144871 835489 175925 184547 716087 237095 248755 263575 824662 274206 278167 371885 698029 971833 308720 315483 184547 441863 274206 354454 587577 366009 366344 315483 367916 371750 711360 371750 402253 403715 404490 412144 434109 441863 810118 4...

output:

500000435543

result:

ok 1 number(s): "500000435543"

Test #28:

score: 0
Accepted
time: 892ms
memory: 97948kb

input:

1000000 20
126110 52385 464710 203919 305450 214423 566044 926946 477145 125830 602550 854825 699058 360960 662325 385240 252572 166915 585008 749718 385240 801236 385240 956433 101385 854825 626672 313521 755479 385240 227584 931898 214423 723758 610608 101385 124880 380048 699058 723758 876575 809...

output:

497932776583

result:

ok 1 number(s): "497932776583"

Test #29:

score: 0
Accepted
time: 919ms
memory: 97704kb

input:

1000000 100
534859 762067 163543 126964 605251 944335 407972 651389 555665 447742 932806 101606 552259 784295 729406 460940 101606 295842 677547 330769 166607 585701 534859 605251 71349 740213 71349 709084 932806 967932 702200 476270 740213 236337 192428 884658 265499 884658 526560 27215 784295 5348...

output:

496316167265

result:

ok 1 number(s): "496316167265"

Test #30:

score: 0
Accepted
time: 770ms
memory: 94952kb

input:

1000000 1000
762444 693573 2802 446818 560172 492832 383822 348558 527640 88414 640787 16618 719592 714819 645316 978131 878247 666414 692106 653890 403061 645316 16618 957721 640654 809285 240678 148559 315034 150418 383822 955234 595812 714819 333549 129451 958145 333549 422540 721509 139762 51676...

output:

494073094584

result:

ok 1 number(s): "494073094584"

Test #31:

score: 0
Accepted
time: 271ms
memory: 66692kb

input:

1000000 10000
698698 886860 655713 894253 100787 686560 716963 105439 783355 784550 8867 698748 541374 365425 49544 783355 112893 596451 515736 445994 515736 194834 596451 137179 894253 348902 515736 209077 698698 445994 230073 110676 235382 698748 87090 787660 596451 594676 938008 327825 483894 923...

output:

500000385825

result:

ok 1 number(s): "500000385825"

Test #32:

score: 0
Accepted
time: 1005ms
memory: 92364kb

input:

1000000 20
923555 989327 140006 149591 154990 770656 408196 595470 474964 537512 108725 16804 179424 723202 299438 427345 153899 332593 919096 234140 554147 754591 426981 640533 138648 838016 395769 701080 444832 776741 144383 602791 344245 178826 617846 276478 281857 670811 182691 876433 89178 1479...

output:

269690150257

result:

ok 1 number(s): "269690150257"

Test #33:

score: 0
Accepted
time: 269ms
memory: 67392kb

input:

1000000 100
894270 701908 348954 29652 46340 7063 218477 942940 128381 502610 965560 831423 440699 564774 550341 990435 852728 397056 625626 506722 608789 551661 828038 357426 842129 239594 347344 536072 940920 913148 87633 180898 670133 473898 500412 890328 196048 945189 695112 11699 368848 217761 ...

output:

495835073299

result:

ok 1 number(s): "495835073299"

Test #34:

score: 0
Accepted
time: 277ms
memory: 66864kb

input:

1000000 1000
146876 535949 746095 349132 639639 361106 286826 779672 175664 75072 511080 451425 511080 867604 802041 924874 223977 90568 525070 953756 85401 434559 380849 375687 483043 441018 90151 649468 624535 342124 886732 351402 99960 31304 403208 821589 808175 938946 827916 887938 802147 612931...

output:

500000500000

result:

ok 1 number(s): "500000500000"

Test #35:

score: 0
Accepted
time: 264ms
memory: 66704kb

input:

1000000 10000
841599 361404 145028 675800 199807 127899 37744 367759 570994 648968 893252 737006 913180 722495 537159 881248 984071 189205 436546 168541 726657 867566 515981 5265 248098 913968 512096 604631 5811 205062 672411 949351 590675 497055 415061 113883 333423 123673 709782 325626 377937 7754...

output:

500000500000

result:

ok 1 number(s): "500000500000"

Test #36:

score: 0
Accepted
time: 535ms
memory: 98012kb

input:

1000000 20
51324 985511 51324 51324 51324 985511 51324 985511 417669 985511 985511 985511 51324 417669 417669 51324 985511 417669 51324 985511 417669 51324 417669 417669 51324 51324 51324 985511 51324 985511 51324 51324 985511 985511 985511 417669 417669 985511 51324 417669 985511 51324 51324 985511...

output:

499992045370

result:

ok 1 number(s): "499992045370"

Test #37:

score: 0
Accepted
time: 526ms
memory: 97956kb

input:

1000000 100
107702 476057 476057 476057 718986 476057 476057 107702 476057 718986 718986 718986 476057 476057 107702 107702 718986 476057 718986 718986 107702 718986 718986 718986 476057 718986 718986 718986 718986 718986 476057 107702 107702 476057 476057 476057 718986 476057 718986 107702 718986 4...

output:

499991755386

result:

ok 1 number(s): "499991755386"

Test #38:

score: 0
Accepted
time: 525ms
memory: 97908kb

input:

1000000 1000
958601 116914 116914 589550 116914 116914 958601 116914 958601 958601 116914 958601 589550 589550 116914 116914 116914 958601 589550 589550 116914 589550 116914 958601 116914 958601 589550 116914 958601 958601 958601 116914 116914 589550 958601 589550 589550 958601 958601 958601 116914 ...

output:

499991601479

result:

ok 1 number(s): "499991601479"

Test #39:

score: 0
Accepted
time: 515ms
memory: 97108kb

input:

1000000 10000
644458 767484 108648 108648 767484 644458 644458 767484 644458 644458 644458 767484 644458 644458 644458 644458 767484 644458 644458 644458 767484 108648 644458 644458 767484 108648 644458 108648 767484 644458 767484 644458 767484 108648 108648 767484 767484 644458 767484 767484 108648...

output:

499991785725

result:

ok 1 number(s): "499991785725"

Test #40:

score: 0
Accepted
time: 834ms
memory: 86436kb

input:

1000000 20
873002 450018 9888 248507 871070 300540 930269 465089 444632 9849 447875 386365 128305 895779 338602 769999 404169 998443 390426 989636 301758 481590 77748 753136 178402 73801 393865 332805 583013 546729 192898 596395 889967 743660 367511 365075 364656 822566 799880 28755 351614 389257 42...

output:

196659308951

result:

ok 1 number(s): "196659308951"

Test #41:

score: 0
Accepted
time: 1048ms
memory: 95712kb

input:

1000000 5
538693 776730 502024 413243 531707 11748 874778 720721 931056 235187 638366 463275 33691 233860 907251 290853 553006 504147 472583 168639 565616 356969 266190 821242 921105 89941 512363 992441 599518 768575 10656 322949 540275 104250 120821 484205 121784 73343 412438 171545 503940 643023 8...

output:

215757902963

result:

ok 1 number(s): "215757902963"

Test #42:

score: 0
Accepted
time: 1029ms
memory: 96484kb

input:

1000000 4
507660 309195 797944 138623 929921 297375 436242 16211 135484 958984 945634 885574 314555 210408 729866 57905 412659 328477 994684 593088 936867 249051 694497 221 18227 940327 428876 254887 838346 13651 468580 500022 226494 906990 132614 321987 653063 152458 474371 843963 616529 31024 5067...

output:

228016732045

result:

ok 1 number(s): "228016732045"

Test #43:

score: 0
Accepted
time: 1039ms
memory: 97156kb

input:

1000000 3
325831 521999 423880 205039 168231 863017 127350 673246 520684 782822 696799 16621 840222 383403 471580 594846 187613 894664 331157 33695 794732 579060 957571 281087 300714 879144 345990 123881 131366 123715 602567 615436 462256 861488 884404 64761 336231 412369 354792 219015 989201 739810...

output:

245821846717

result:

ok 1 number(s): "245821846717"