QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#636001#8628. 最大连续和wzj3330050 208ms3988kbC++2316.1kb2024-10-12 21:46:582024-10-12 21:46:59

Judging History

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

  • [2024-10-12 21:46:59]
  • 评测
  • 测评结果:50
  • 用时:208ms
  • 内存:3988kb
  • [2024-10-12 21:46:58]
  • 提交

answer

/**
  * created     : 12.10.2024 20:25:04
  * author      : wzj33300
  */

#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
#include <algo/debug.h>
#else
#define debug(...) 42
#define assert(...) 42
#endif

using ll = long long;
using u32 = unsigned int;
using u64 = unsigned long long;
using db = long double;  // or double, if TL is tight
using str = string;      // yay python!

// pairs
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using pd = pair<db, db>;
#define mp make_pair
#define fi first
#define se second

// ^ lol this makes everything look weird but I'll try it
template <class T>
using vc = vector<T>;
template <class T, size_t SZ>
using AR = array<T, SZ>;
using vi = vc<int>;
using vb = vc<bool>;
using vl = vc<ll>;
using vd = vc<db>;
using vs = vc<str>;
using vpi = vc<pi>;
using vpl = vc<pl>;
using vpd = vc<pd>;

// vectors
// oops size(x), rbegin(x), rend(x) need C++17
#define sz(x) int((x).size())
#define bg(x) begin(x)
#define all(x) bg(x), end(x)
#define rall(x) x.rbegin(), x.rend()
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define pb push_back
#define eb emplace_back
#define ft front()
#define bk back()

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
#define rep1n(i, n) for (int i = 1; i <= (n); ++i)
#define repr(i, n) for (int i = (n) - 1; i >= 0; --i)

#define rep_subset(t, s) \
  for (ll t = (s); t >= 0; t = (t == 0 ? -1 : (t - 1) & (s)))

#define lb lower_bound
#define ub upper_bound
template <class T>
int lwb(vc<T>& a, const T& b) {
  return int(lb(all(a), b) - bg(a));
}
template <class T>
int upb(vc<T>& a, const T& b) {
  return int(ub(all(a), b) - bg(a));
}
// const int MOD = 998244353;  // 1e9+7;
const int Big = 1e9;  // not too close to INT_MAX
const ll BIG = 1e18;  // not too close to LLONG_MAX
const db PI = acos((db)-1);
const int dx[4]{1, 0, -1, 0}, dy[4]{0, 1, 0, -1};  // for every grid problem!!
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());
template <class T>
using pqg = priority_queue<T, vector<T>, greater<T>>;

int pct(int x) { return __builtin_popcount(x); }
int pct(u32 x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }
int pct(u64 x) { return __builtin_popcountll(x); }
int popcnt_mod_2(int x) { return __builtin_parity(x); }
int popcnt_mod_2(u32 x) { return __builtin_parity(x); }
int popcnt_mod_2(ll x) { return __builtin_parityll(x); }
int popcnt_mod_2(u64 x) { return __builtin_parityll(x); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 1, 2)
int topbit(int x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(u32 x) { return (x == 0 ? -1 : 31 - __builtin_clz(x)); }
int topbit(ll x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
int topbit(u64 x) { return (x == 0 ? -1 : 63 - __builtin_clzll(x)); }
// (0, 1, 2, 3, 4) -> (-1, 0, 1, 0, 2)
int lowbit(int x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(u32 x) { return (x == 0 ? -1 : __builtin_ctz(x)); }
int lowbit(ll x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }
int lowbit(u64 x) { return (x == 0 ? -1 : __builtin_ctzll(x)); }

template <typename T>
T floor(T a, T b) {
  return a / b - (a % b && (a ^ b) < 0);
}
template <typename T>
T ceil(T x, T y) {
  return floor(x + y - 1, y);
}
template <typename T>
T bmod(T x, T y) {
  return x - y * floor(x, y);
}
template <typename T>
pair<T, T> divmod(T x, T y) {
  T q = floor(x, y);
  return {q, x - q * y};
}

template <class T>
bool ckmin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}  // set a = min(a,b)
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}  // set a = max(a,b)

template <class T, class U>
T fstTrue(T lo, T hi, U f) {
  ++hi;
  assert(lo <= hi);  // assuming f is increasing
  while (lo < hi) {  // find first index such that f is true
    T mid = lo + (hi - lo) / 2;
    f(mid) ? hi = mid : lo = mid + 1;
  }
  return lo;
}
template <class T, class U>
T lstTrue(T lo, T hi, U f) {
  --lo;
  assert(lo <= hi);  // assuming f is decreasing
  while (lo < hi) {  // find first index such that f is true
    T mid = lo + (hi - lo + 1) / 2;
    f(mid) ? lo = mid : hi = mid - 1;
  }
  return lo;
}

namespace seg_tree {

// Floor of log_2(a); index of highest 1-bit
inline int floor_log_2(int a) {
  return a ? bit_width(unsigned(a)) - 1 : -1;
}

struct point {
  int a;
  point() : a(0) {}
  explicit point(int a_) : a(a_) { assert(a >= -1); }

  explicit operator bool() { return bool(a); }

  // This is useful so you can directly do array indices
  /* implicit */ operator int() const { return a; }

  point c(bool z) const {
    return point((a << 1) | z);
  }

  point operator[](bool z) const {
    return c(z);
  }

  point p() const {
    return point(a >> 1);
  }

  friend std::ostream& operator<<(std::ostream& o, const point& p) { return o << int(p); }

  template <typename F>
  void for_each(F f) const {
    for (int v = a; v > 0; v >>= 1) {
      f(point(v));
    }
  }

  template <typename F>
  void for_parents_down(F f) const {
    // strictly greater than 0
    for (int L = floor_log_2(a); L > 0; L--) {
      f(point(a >> L));
    }
  }

  template <typename F>
  void for_parents_up(F f) const {
    for (int v = a >> 1; v > 0; v >>= 1) {
      f(point(v));
    }
  }

  point& operator++() {
    ++a;
    return *this;
  }
  point operator++(int) { return point(a++); }
  point& operator--() {
    --a;
    return *this;
  }
  point operator--(int) { return point(a--); }
};

struct range {
  int a, b;
  range() : a(1), b(1) {}
  range(int a_, int b_) : a(a_), b(b_) {
    assert(1 <= a && a <= b && b <= 2 * a);
  }
  explicit range(std::array<int, 2> r) : range(r[0], r[1]) {}

  explicit operator std::array<int, 2>() const {
    return {a, b};
  }

  const int& operator[](bool z) const {
    return z ? b : a;
  }

  friend std::ostream& operator<<(std::ostream& o, const range& r) { return o << "[" << r.a << ".." << r.b << ")"; }

  // Iterate over the range from outside-in.
  //   Calls f(point a)
  template <typename F>
  void for_each(F f) const {
    for (int x = a, y = b; x < y; x >>= 1, y >>= 1) {
      if (x & 1) f(point(x++));
      if (y & 1) f(point(--y));
    }
  }

  // Iterate over the range from outside-in.
  //   Calls f(point a, bool is_right)
  template <typename F>
  void for_each_with_side(F f) const {
    for (int x = a, y = b; x < y; x >>= 1, y >>= 1) {
      if (x & 1) f(point(x++), false);
      if (y & 1) f(point(--y), true);
    }
  }

  // Iterate over the range from left to right.
  //    Calls f(point)
  template <typename F>
  void for_each_l_to_r(F f) const {
    int anc_depth = floor_log_2((a - 1) ^ b);
    int anc_msk = (1 << anc_depth) - 1;
    for (int v = (-a) & anc_msk; v; v &= v - 1) {
      int i = countr_zero(unsigned(v));
      f(point(((a - 1) >> i) + 1));
    }
    for (int v = b & anc_msk; v;) {
      int i = floor_log_2(v);
      f(point((b >> i) - 1));
      v ^= (1 << i);
    }
  }

  // Iterate over the range from right to left.
  //    Calls f(point)
  template <typename F>
  void for_each_r_to_l(F f) const {
    int anc_depth = floor_log_2((a - 1) ^ b);
    int anc_msk = (1 << anc_depth) - 1;
    for (int v = b & anc_msk; v; v &= v - 1) {
      int i = countr_zero(unsigned(v));
      f(point((b >> i) - 1));
    }
    for (int v = (-a) & anc_msk; v;) {
      int i = floor_log_2(v);
      f(point(((a - 1) >> i) + 1));
      v ^= (1 << i);
    }
  }

  template <typename F>
  void for_parents_down(F f) const {
    int x = a, y = b;
    if ((x ^ y) > x) {
      x <<= 1, std::swap(x, y);
    }
    int dx = countr_zero(unsigned(x));
    int dy = countr_zero(unsigned(y));
    int anc_depth = floor_log_2((x - 1) ^ y);
    for (int i = floor_log_2(x); i > dx; i--) {
      f(point(x >> i));
    }
    for (int i = anc_depth; i > dy; i--) {
      f(point(y >> i));
    }
  }

  template <typename F>
  void for_parents_up(F f) const {
    int x = a, y = b;
    if ((x ^ y) > x) {
      x <<= 1, std::swap(x, y);
    }
    int dx = countr_zero(unsigned(x));
    int dy = countr_zero(unsigned(y));
    int anc_depth = floor_log_2((x - 1) ^ y);
    for (int i = dx + 1; i <= anc_depth; i++) {
      f(point(x >> i));
    }
    for (int v = y >> (dy + 1); v; v >>= 1) {
      f(point(v));
    }
  }
};

struct in_order_layout {
  // Alias them in for convenience
  using point = seg_tree::point;
  using range = seg_tree::range;

  int n, s;
  in_order_layout() : n(0), s(0) {}
  in_order_layout(int n_) : n(n_), s(n ? bit_ceil(unsigned(n)) : 0) {}

  point get_point(int a) const {
    assert(0 <= a && a < n);
    a += s;
    return point(a >= 2 * n ? a - n : a);
  }

  range get_range(int a, int b) const {
    assert(0 <= a && a <= b && b <= n);
    if (n == 0) return range();
    a += s, b += s;
    return range((a >= 2 * n ? 2 * (a - n) : a), (b >= 2 * n ? 2 * (b - n) : b));
  }

  range get_range(std::array<int, 2> p) const {
    return get_range(p[0], p[1]);
  }

  int get_leaf_index(point pt) const {
    int a = int(pt);
    assert(n <= a && a < 2 * n);
    return (a < s ? a + n : a) - s;
  }

  std::array<int, 2> get_node_bounds(point pt) const {
    int a = int(pt);
    assert(1 <= a && a < 2 * n);
    int l = countl_zero(unsigned(a)) - countl_zero(unsigned(2 * n - 1));
    int x = a << l, y = (a + 1) << l;
    assert(s <= x && x < y && y <= 2 * s);
    return {(x >= 2 * n ? (x >> 1) + n : x) - s, (y >= 2 * n ? (y >> 1) + n : y) - s};
  }

  int get_node_split(point pt) const {
    int a = int(pt);
    assert(1 <= a && a < n);
    int l = countl_zero(unsigned(2 * a + 1)) - countl_zero(unsigned(2 * n - 1));
    int x = (2 * a + 1) << l;
    assert(s <= x && x < 2 * s);
    return (x >= 2 * n ? (x >> 1) + n : x) - s;
  }

  int get_node_size(point pt) const {
    auto bounds = get_node_bounds(pt);
    return bounds[1] - bounds[0];
  }
};

struct circular_layout {
  // Alias them in for convenience
  using point = seg_tree::point;
  using range = seg_tree::range;

  int n;
  circular_layout() : n(0) {}
  circular_layout(int n_) : n(n_) {}

  point get_point(int a) const {
    assert(0 <= a && a < n);
    return point(n + a);
  }

  range get_range(int a, int b) const {
    assert(0 <= a && a <= b && b <= n);
    if (n == 0) return range();
    return range(n + a, n + b);
  }

  range get_range(std::array<int, 2> p) const {
    return get_range(p[0], p[1]);
  }

  int get_leaf_index(point pt) const {
    int a = int(pt);
    assert(n <= a && a < 2 * n);
    return a - n;
  }

  // Returns {x,y} so that 0 <= x < n and 1 <= y <= n
  // If the point is non-wrapping, then 0 <= x < y <= n
  std::array<int, 2> get_node_bounds(point pt) const {
    int a = int(pt);
    assert(1 <= a && a < 2 * n);
    int l = countl_zero(unsigned(a)) - countl_zero(unsigned(2 * n - 1));
    int s = bit_ceil(unsigned(n));
    int x = a << l, y = (a + 1) << l;
    assert(s <= x && x < y && y <= 2 * s);
    return {(x >= 2 * n ? x >> 1 : x) - n, (y > 2 * n ? y >> 1 : y) - n};
  }

  // Returns the split point of the node, such that 1 <= s <= n.
  int get_node_split(point pt) const {
    int a = int(pt);
    assert(1 <= a && a < n);
    return get_node_bounds(pt.c(0))[1];
  }

  int get_node_size(point pt) const {
    auto bounds = get_node_bounds(pt);
    int r = bounds[1] - bounds[0];
    return r > 0 ? r : r + n;
  }
};

}  // namespace seg_tree

template <typename Info>
class SimpleSegmentTree {
 public:
  int n;
  vector<Info> infos;
  seg_tree::in_order_layout layout;

  void UpdateNode(seg_tree::point a) {
    infos[a] = infos[a.c(0)].Unite(infos[a.c(1)]);
  }

  SimpleSegmentTree(int n_) : SimpleSegmentTree(vector<Info>(n_)) {}

  SimpleSegmentTree(const vector<Info>& a) : n(int(a.size())) {
    assert(n > 0);
    infos.resize(2 * n);
    layout = seg_tree::in_order_layout(n);
    for (int i = 0; i < n; i++) {
      infos[layout.get_point(i)] = a[i];
    }
    for (int i = n - 1; i >= 1; i--) {
      infos[i] = infos[2 * i].Unite(infos[2 * i + 1]);
    }
  }

  void Set(int p, const Info& v) {
    auto pt = layout.get_point(p);
    infos[pt] = v;
    pt.for_parents_up([&](seg_tree::point a) {
      UpdateNode(a);
    });
  }

  Info Query(int l, int r) {
    auto rng = layout.get_range(l, r);
    Info res;
    rng.for_each_l_to_r([&](seg_tree::point a) {
      res = res.Unite(infos[a]);
    });
    return res;
  }

  Info Get(int p) {
    auto pt = layout.get_point(p);
    return infos[pt];
  }

  template <typename F>
  int MaxRight(int l, F f) {
    auto rng = layout.get_range(l, n);
    int res = n;
    Info sum;
    rng.for_each_l_to_r([&](seg_tree::point a) {
      if (res != n) {
        return;
      }
      auto new_sum = sum.Unite(infos[a]);
      if (f(new_sum)) {
        sum = new_sum;
        return;
      }
      while (a < n) {
        new_sum = sum.Unite(infos[a.c(0)]);
        if (f(new_sum)) {
          sum = new_sum;
          a = a.c(1);
        } else {
          a = a.c(0);
        }
      }
      res = layout.get_node_bounds(a)[0];
    });
    return res;
  }

  template <typename F>
  int MinLeft(int r, F f) {
    auto rng = layout.get_range(0, r);
    int res = 0;
    Info sum;
    rng.for_each_r_to_l([&](seg_tree::point a) {
      if (res != 0) {
        return;
      }
      auto new_sum = infos[a].Unite(sum);
      if (f(new_sum)) {
        sum = new_sum;
        return;
      }
      while (a < n) {
        new_sum = infos[a.c(1)].Unite(sum);
        if (f(new_sum)) {
          sum = new_sum;
          a = a.c(0);
        } else {
          a = a.c(1);
        }
      }
      res = layout.get_node_bounds(a)[1];
    });
    return res;
  }
};

struct Info {
  int mx = 0, cnt = 0;
  ll sum = 0;

  Info Unite(Info b) const {
    Info res;
    res.mx = std::max(mx, b.mx), res.cnt = cnt + b.cnt, res.sum = sum + b.sum;
    return res;
  }

  static Info GetDefault([[maybe_unused]] int l, [[maybe_unused]] int r) {
    return Info();
  }
};

// signed main() {
int main() {
  // freopen(".in", "r",stdin);
  // freopen(".out","w",stdout);
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  std::cin >> n >> m;
  vi a(n), b(m), al;
  for (auto& i : a) std::cin >> i, al.eb(i);
  for (auto& i : b) std::cin >> i, al.eb(i);
  std::sort(all(b), greater());
  b.resize(n, -Big * 2);
  std::sort(all(al));
  al.erase(std::unique(all(al)), al.end());
  int N = sz(al);
  vl sa(n + 1), sb(m + 1);
  for (int i = 0; i < n; i++) sa[i + 1] = sa[i] + a[i], a[i] = lwb(al, a[i]);
  for (int i = 0; i < m; i++) sb[i + 1] = sb[i] + b[i], b[i] = lwb(al, b[i]);

  SimpleSegmentTree<Info> tr(n);

  vi buc(N);
  for (int i = 0; i < n; i++) buc[a[i]]++;
  for (int i = 1; i < N; i++) buc[i] += buc[i - 1];
  buc.insert(buc.begin(), 0), buc.pop_back();
  auto add = [&](int x) {
    tr.Set(buc[x]++, Info{x, 1, al[x]});
  };
  auto del = [&](int x) {
    tr.Set(--buc[x], Info{0, 0, 0});
  };
  int L = 0, R = -1;
  auto div = [&](auto&& div, int l, int r, int pl, int pr) -> ll {
    debug(l, r, pl, pr);
    if (l > r) return -BIG;
    int mid = l + r >> 1;
    while (L > pl) add(a[--L]);
    while (R < std::min(mid, pr)) add(a[++R]);
    while (L < pl) del(a[L++]);
    while (R > std::min(mid, pr)) del(a[R--]);
    ll ans = -BIG;
    int p;
    while (L <= std::min(mid, pr)) {
      int k = tr.MaxRight(0, [&](const Info& x) {
        debug(x.cnt);
        if (x.cnt == 0) return true;
        return x.mx < b[x.cnt - 1];
      });
      auto c = tr.Query(0, k);
      ll ansnow = sa[mid + 1] - sa[L] - c.sum + sb[c.cnt];
      if (ans <= ansnow) ans = ansnow, p = L;
      del(a[L++]);
    }
    return std::max({ans, div(div, l, mid - 1, 0, n - 1), div(div, mid + 1, r, 0, n - 1)});
  };
  std::cout << div(div, 0, n - 1, 0, n - 1);
  return 0;
}

/*

找到最后一个 k 满足 a_k<b_k a从小到大排序 b从大到小排序 满足单调性 线段树二分

注意处理a相等的情况

*/

详细

Subtask #1:

score: 20
Accepted

Test #1:

score: 20
Accepted
time: 11ms
memory: 3876kb

input:

497 404
917535854 939575385 985070918 788445476 990228874 890712076 973415095 975904486 794872088 958037942 894373426 975435251 821587328 898697908 848044776 985486749 977595334 985578214 961966222 967928299 846072308 998679302 989797646 987698522 755351683 893841487 986707387 832412612 973338351 92...

output:

483851132608

result:

ok 1 number(s): "483851132608"

Test #2:

score: 20
Accepted
time: 10ms
memory: 3672kb

input:

496 13
975537796 867824005 731905698 995044734 980663118 979671628 948113905 961691035 916377605 973634815 963676914 968266658 845279779 967647040 977551474 953069751 898164359 800993445 967373577 926295172 961939352 971469513 966783255 983637364 942997390 909279266 924009236 991590090 999500351 997...

output:

464615676533

result:

ok 1 number(s): "464615676533"

Test #3:

score: 20
Accepted
time: 10ms
memory: 3648kb

input:

494 199
926827016 952344126 978952774 984160671 764453527 987217588 966884035 829168774 892004441 970379925 925734206 998053653 983696512 931554802 998190181 975325858 956456983 952308401 845098341 900126151 893590537 890004652 961645284 920444541 812442265 884028508 876051681 993154406 984329290 99...

output:

463658462826

result:

ok 1 number(s): "463658462826"

Test #4:

score: 20
Accepted
time: 9ms
memory: 3648kb

input:

496 435
975646956 814674762 933529180 904994688 992678370 946706784 839906774 902317711 845422273 972194139 813046404 976785034 926131373 974302545 966840750 924436144 999089868 920682206 984450286 892340175 836194192 986242403 984116213 957559067 968849870 990168285 992136115 901729940 991291097 92...

output:

463114056080

result:

ok 1 number(s): "463114056080"

Test #5:

score: 20
Accepted
time: 10ms
memory: 3656kb

input:

497 489
898057732 989350547 954829689 790197266 859303628 983031071 956944099 939660671 949124411 946421616 976130798 981356584 915782576 979122086 904840012 980931407 999980689 967703811 841746659 908116108 923941319 940951715 845271665 973944748 977355661 979677029 882851568 989147339 892312893 99...

output:

468369265315

result:

ok 1 number(s): "468369265315"

Test #6:

score: 20
Accepted
time: 11ms
memory: 3656kb

input:

496 272
726660517 988027147 641363792 893562116 549283098 782136280 899598073 596901908 739451367 873639418 552800606 703209382 900348150 994027130 724992439 912230131 973506276 724878823 952223459 873259274 972970499 404285830 905899171 820178381 955212498 445875007 700057246 902325804 639224576 63...

output:

458091940524

result:

ok 1 number(s): "458091940524"

Test #7:

score: 20
Accepted
time: 11ms
memory: 3644kb

input:

490 223
439120519 836751136 983682873 964431861 636949330 689735411 385164421 987116695 938125692 722862070 205619236 867761402 842681679 767751623 964270927 770725068 517405838 856820462 951312608 819473134 992226812 643047101 967409521 941853731 632454709 695808935 911367302 981984788 916120947 76...

output:

426229223625

result:

ok 1 number(s): "426229223625"

Test #8:

score: 20
Accepted
time: 7ms
memory: 3872kb

input:

481 132
835595156 681662205 991389219 964689424 984331285 622719180 643002953 861572373 452059382 959871719 526907681 510233909 996061844 915035116 861927997 960409110 972413672 820764693 891367410 980338714 887679775 696912724 145341355 863681485 857026243 928884034 571306267 893026670 821828400 72...

output:

407092001521

result:

ok 1 number(s): "407092001521"

Test #9:

score: 20
Accepted
time: 10ms
memory: 3880kb

input:

495 396
792108807 988116882 993430688 646570027 744353493 939746552 764749385 850820381 912542822 905528475 602526359 792011347 719629521 970537265 857896451 731783358 813613412 592113897 916099093 996240514 834276312 845805166 951874573 658126641 851091218 872259565 870073547 776430057 425576801 95...

output:

408031495738

result:

ok 1 number(s): "408031495738"

Test #10:

score: 20
Accepted
time: 8ms
memory: 3680kb

input:

461 247
391372183 695346715 991402090 902646167 775594916 896725173 757297041 646856690 994028068 828803678 910322516 965710977 941604590 886440221 957935863 761236333 669009487 995655163 871361848 977615683 796633010 976776285 816265478 864414212 819773056 388783099 780222345 887743482 857535582 95...

output:

368869407315

result:

ok 1 number(s): "368869407315"

Test #11:

score: 20
Accepted
time: 11ms
memory: 3624kb

input:

487 334
996281271 862464604 622744320 814499773 754628021 851460680 918694626 39285382 650964328 831886931 929713122 578688377 924893457 842180700 748582354 941122642 550959196 750369461 865176891 531329055 557571901 812575496 658603095 337458635 820011582 824870862 586941807 472406148 820075350 864...

output:

453838728864

result:

ok 1 number(s): "453838728864"

Test #12:

score: 20
Accepted
time: 11ms
memory: 3836kb

input:

493 72
907831353 571218453 435958224 943107973 557600940 927246770 880201908 101455028 740762214 814956609 468651801 630674133 575848868 -116604518 628657047 915488065 831931284 787078668 983078731 300536627 721552796 952014617 432770864 165812699 998937307 966960444 915191314 941801284 719412168 77...

output:

355272500499

result:

ok 1 number(s): "355272500499"

Test #13:

score: 20
Accepted
time: 11ms
memory: 3844kb

input:

496 255
998713362 180066866 934188786 786211914 887099152 768935168 928203690 589812295 426156018 292836387 -467893109 447047134 316891941 18356045 -45277721 473671229 987123183 946497643 106990737 -75033507 519450404 928327604 658416390 887127703 -296029611 126420130 946877185 230361952 681073211 1...

output:

312356286990

result:

ok 1 number(s): "312356286990"

Test #14:

score: 20
Accepted
time: 10ms
memory: 3648kb

input:

479 236
-313122148 -426574095 674458385 604324937 591256414 560462865 -621113053 516353462 828266938 -582302937 907236038 954900038 962966676 -215448454 85560851 376227000 -192784574 942773596 -516410153 44326228 237427256 81122647 611042704 986071460 748795250 858284392 716087257 564632850 99167608...

output:

180319805621

result:

ok 1 number(s): "180319805621"

Test #15:

score: 20
Accepted
time: 9ms
memory: 3644kb

input:

457 231
306159981 697396736 877656289 776668303 -240030450 624990360 142298458 764210618 820932501 853942279 626019848 961200573 517128714 394862481 207231691 998003063 487733250 571427117 831892676 655665372 850639673 346775450 411747592 643104720 127294795 934342584 -58923091 402324981 987575927 9...

output:

276008599754

result:

ok 1 number(s): "276008599754"

Test #16:

score: 20
Accepted
time: 10ms
memory: 3832kb

input:

496 6
-933688337 38619567 118597697 125121684 -708544757 -663304796 -889641463 320428847 315063502 -999749701 -988894490 -673635545 -831159616 -654935670 222099837 173112793 180560458 389171870 -281457718 -919789933 -632124252 443134587 -798537127 -586929942 -922568428 -803390902 -159804784 -5091063...

output:

8262243011

result:

ok 1 number(s): "8262243011"

Test #17:

score: 20
Accepted
time: 10ms
memory: 3624kb

input:

500 168
-650635678 -850850912 -708800712 -285715966 -711195026 -827269654 -672629771 -706637171 -478130086 -740787488 -310431832 -432550205 -887070947 -788652522 -361220625 -488343691 -231945683 -959450880 -452805056 -893514879 51974114 -2384377 -954629320 -624401795 -946080197 443751543 -364024858 ...

output:

116216458334

result:

ok 1 number(s): "116216458334"

Test #18:

score: 20
Accepted
time: 10ms
memory: 3712kb

input:

477 214
-719990948 -669486096 -756533330 -1655250 -811273933 -850987570 -358027378 -852733569 -436580218 -759427203 -763207772 -870791180 -520377039 -860253103 -649625851 -876796170 -788443639 -688204863 -607707866 443861344 -246028680 -904089187 -761268066 -784526445 -935139850 -649937306 -99329569...

output:

20387620616

result:

ok 1 number(s): "20387620616"

Test #19:

score: 20
Accepted
time: 11ms
memory: 3700kb

input:

495 26
-898758488 -412437944 -506327126 -88683121 -895477751 -902081002 -940819018 8208920 -810397811 -922405042 -939550091 -936409427 -537998390 -314752672 -619473213 -934541312 -910086480 -287606446 -687470794 -292673023 -494139923 -712542161 -697857233 -792835541 -443206745 -864178619 -856223497 ...

output:

702738541

result:

ok 1 number(s): "702738541"

Test #20:

score: 20
Accepted
time: 11ms
memory: 3636kb

input:

496 86
-784392819 -413361783 -959542957 -759228646 -467712077 -115772347 -929891936 -386870348 -506823714 -906750776 -915372779 -752463256 -119629587 -895299124 -880284517 -537927390 -902117310 -684347435 -749515914 -815583179 31243673 -283874921 -49062903 -891291906 93099457 -920002198 -947366831 -...

output:

805086346

result:

ok 1 number(s): "805086346"

Test #21:

score: 20
Accepted
time: 8ms
memory: 3648kb

input:

486 484
-895424149 -918033993 -803885890 -797415008 -855236287 -846264011 -904538470 -900153042 -822640990 -866356034 -952067144 -893444302 -889418808 -839585251 -987356464 -730401344 -895427431 -737358162 -685475821 -508041967 -751675055 -559236420 -858149297 -991549117 -518756667 -898234311 -98592...

output:

435314825228

result:

ok 1 number(s): "435314825228"

Test #22:

score: 20
Accepted
time: 6ms
memory: 3648kb

input:

488 246
-313311000 -960231854 -812666552 -330842050 -535931879 -985388614 -794860137 -979990915 -635093776 -973855770 -831598293 -803751405 -423513613 -839407265 -317219399 -996878400 -906555179 -974381660 -914824152 -742863055 -800370245 -974597766 -726845366 -882142483 -934489842 -656133651 -80767...

output:

179230944009

result:

ok 1 number(s): "179230944009"

Test #23:

score: 20
Accepted
time: 9ms
memory: 3628kb

input:

496 459
-939255344 -926912303 -642418223 -667809425 -891920612 -781225664 -927164548 -561068134 -885783023 -702008889 -976803004 -924212478 -413435691 -762521751 -253808291 -982156287 -898921992 -921290091 -921942779 -863488654 -946353135 -956814042 -533299333 -816545326 -662247210 -981131156 -99282...

output:

34951943968

result:

ok 1 number(s): "34951943968"

Test #24:

score: 20
Accepted
time: 11ms
memory: 3596kb

input:

500 302
-493431618 -677323871 -924687063 -483182864 -871510109 -580361880 -801555458 -638077584 -738789285 -842145891 -990865398 -856752584 -67677016 -753626370 -697998062 -896773173 -914560089 -926742893 -556129066 -951488633 -906646248 -534674026 -651039816 -733016632 -665629691 -394501083 -838765...

output:

1549585910

result:

ok 1 number(s): "1549585910"

Test #25:

score: 20
Accepted
time: 7ms
memory: 3652kb

input:

500 468
-999452671 -956377240 -841520046 -667304682 -913912446 -875365463 -955946457 -966723472 -697574514 -600951169 -234845656 -985026539 -103070463 -962259855 -731507799 -762798845 -675316894 -832704913 -828275582 -679716323 -975959471 -915642013 -601410260 -915472981 -763923828 -556913779 -90629...

output:

221022788

result:

ok 1 number(s): "221022788"

Test #26:

score: 20
Accepted
time: 10ms
memory: 3636kb

input:

493 127
-997302663 -949411198 -994016331 -987048681 -620565350 -961290066 -942675276 -782668341 -972247629 -971446966 -940214148 -981116023 -830414015 -986934780 -995700692 -811130304 -943099505 -938379807 -920959816 -988076696 -936985688 -856818232 -914481193 -966318221 -987747949 -948884288 -89160...

output:

116693689661

result:

ok 1 number(s): "116693689661"

Test #27:

score: 20
Accepted
time: 6ms
memory: 3640kb

input:

496 279
-921839635 -915247468 -607973702 -992986261 -826114315 -996323348 -950182550 -883207866 -994434247 -947141846 -921853305 -794879448 -982658561 -861115701 -988641608 -968041800 -896821480 -688277817 -978019293 -919460766 -947908059 -995766620 -949297203 -961777011 -972441046 -981479046 -91652...

output:

206139221719

result:

ok 1 number(s): "206139221719"

Test #28:

score: 20
Accepted
time: 11ms
memory: 3700kb

input:

497 94
-928741134 -971913060 -944774187 -888318981 -975672453 -857960653 -989514979 -934185109 -994942497 -820096443 -905465743 -990548185 -904460759 -888051312 -940880854 -981230832 -983000129 -943873695 -976872665 -902903242 -902581305 -731368746 -995869282 -951028626 -918065732 -990048310 -978589...

output:

5261762361

result:

ok 1 number(s): "5261762361"

Test #29:

score: 20
Accepted
time: 10ms
memory: 3840kb

input:

487 275
-991622382 -790342891 -928212953 -983040443 -957020484 -993204686 -821911262 -792638057 -929896026 -974789633 -777415316 -971098472 -950400651 -900881890 -977133576 -950827424 -907828247 -931934256 -955715664 -909712328 -857655212 -813667729 -990215131 -836879859 -953821640 -971616583 -75119...

output:

350460202

result:

ok 1 number(s): "350460202"

Test #30:

score: 20
Accepted
time: 11ms
memory: 3636kb

input:

496 161
-918172379 -994898747 -891843540 -986244396 -985677374 -897455184 -996575291 -730665069 -768125341 -990407257 -979552537 -994481326 -974132598 -809583016 -996637728 -903188406 -907873331 -958378099 -995795233 -983031481 -964145102 -992507094 -923042393 -649322772 -857803430 -929138772 -86168...

output:

-502000194

result:

ok 1 number(s): "-502000194"

Test #31:

score: 20
Accepted
time: 8ms
memory: 3644kb

input:

500 500
-1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -100...

output:

500000000000

result:

ok 1 number(s): "500000000000"

Test #32:

score: 20
Accepted
time: 10ms
memory: 3640kb

input:

500 0
-705868120 437944801 -994664067 -945123199 235636099 -580472208 301040695 849655790 -28866864 669222862 -329010858 620645775 -746647813 379130864 299907933 -140797390 -373540198 172740593 531140065 -793928319 73759090 869528397 801867581 -329154244 245008607 863877142 904027120 -875163747 7238...

output:

25685887295

result:

ok 1 number(s): "25685887295"

Test #33:

score: 20
Accepted
time: 1ms
memory: 3628kb

input:

106 500
-973296305 -991270071 -999777741 -945419919 -921696259 -982669544 -992045606 -981404943 -984753830 -880902613 -967549531 -971988671 -991259570 -997515081 -995674660 -999679388 -993723521 -984057435 -999387958 -999382496 -987396940 -992111297 -994335472 -993575210 -997674041 -987019963 -97904...

output:

105728405567

result:

ok 1 number(s): "105728405567"

Test #34:

score: 20
Accepted
time: 0ms
memory: 3624kb

input:

78 500
-979003243 -783182055 -797906251 -791612407 -707996068 -980039454 -674883344 -898500732 -785918263 232920289 -782302693 -875333230 -534949572 -971893158 -368945772 -900477684 -530952239 -125000175 -480788471 -807687824 -951814036 -974306406 -901065420 -696566877 -615952020 -680152514 -8357593...

output:

74585672077

result:

ok 1 number(s): "74585672077"

Test #35:

score: 20
Accepted
time: 6ms
memory: 3704kb

input:

379 500
81445644 978254865 -83001343 407942121 872382989 296007807 948950287 607967134 887745502 978081016 668949034 -244895071 747137177 753977515 981953535 369793121 566921076 458860912 673489527 249588863 299250886 529302875 476309668 129175311 386968100 212213275 -77401903 619011822 610248010 88...

output:

360900628422

result:

ok 1 number(s): "360900628422"

Subtask #2:

score: 30
Accepted

Dependency #1:

100%
Accepted

Test #36:

score: 30
Accepted
time: 204ms
memory: 3808kb

input:

1967 481
960158889 986941651 946048616 999722353 921474155 980060696 990075278 917433264 913442510 869984420 911613313 780063576 991137069 942018535 987522854 919724378 909450946 986733135 938211578 989518379 987125164 969066537 803288983 781749396 977165586 914760637 978951785 786564842 940128815 9...

output:

1878963439313

result:

ok 1 number(s): "1878963439313"

Test #37:

score: 30
Accepted
time: 188ms
memory: 3680kb

input:

1998 68
980110773 990384396 931811504 985022248 834438376 999189833 967932077 999889061 976913472 998168028 997848728 959733348 998637891 999727117 968721849 951286061 905085594 831095342 750833717 955138834 973793842 878673458 918325168 934873899 958905417 825992012 992712112 912263795 840239685 99...

output:

1876011817844

result:

ok 1 number(s): "1876011817844"

Test #38:

score: 30
Accepted
time: 199ms
memory: 3748kb

input:

1994 1447
982755043 944751805 940206958 925141492 970211760 915881871 973619608 979349148 958140592 762488176 962909441 864210002 830605876 926019545 996835310 995100204 951066285 997381009 943309263 909553127 937030925 929812837 941225934 773930341 919231065 974618611 918895875 908287213 926652444 ...

output:

1892100071205

result:

ok 1 number(s): "1892100071205"

Test #39:

score: 30
Accepted
time: 169ms
memory: 3732kb

input:

1998 203
996230183 956543040 999518630 872218479 942197165 989084992 987042361 967162304 996679678 996109808 997450715 927513067 833971473 958567818 849238315 969558276 906711069 981743572 940332901 958882708 990109151 981515760 933945700 968374907 980095501 947358993 988296996 982431426 973745078 8...

output:

1876947189120

result:

ok 1 number(s): "1876947189120"

Test #40:

score: 30
Accepted
time: 168ms
memory: 3720kb

input:

1998 1475
965419675 938591734 981831723 907212420 903107043 994705261 950080097 967059888 999311953 996994018 997168770 979404125 945729584 999379019 928984424 972033440 984819879 997850473 799919147 900448166 855363709 984270050 964225291 967417776 955835275 832730645 929072582 949669915 965698566 ...

output:

1871226174895

result:

ok 1 number(s): "1871226174895"

Test #41:

score: 30
Accepted
time: 202ms
memory: 3740kb

input:

1962 1144
842548725 827282677 847832652 715791992 112614192 485046978 945773454 60989372 614242743 945831111 634309634 651604907 706418615 873794708 355711197 695844362 389024808 971621173 686041503 940117821 902546976 806242090 739175594 679504481 589485016 611650073 933953671 891576974 822827170 4...

output:

1804805516201

result:

ok 1 number(s): "1804805516201"

Test #42:

score: 30
Accepted
time: 205ms
memory: 3740kb

input:

1993 944
993261394 598376143 959216364 893666909 913852934 976931878 690756676 823049592 912249025 743271270 864330022 559238557 358779428 595964939 725902010 869455193 833426766 643685902 523047066 945897902 814125892 774244113 896278994 932905503 131290426 898696000 412637085 728936925 345956680 7...

output:

1670812413609

result:

ok 1 number(s): "1670812413609"

Test #43:

score: 30
Accepted
time: 184ms
memory: 3940kb

input:

1990 1524
867422753 985863693 914226166 930736108 590306279 876256621 799378541 501518190 871383427 903580361 978938201 993336845 865074482 931357991 969046166 970794838 700407755 691095973 999737354 990234982 894623532 916926453 631942801 817638026 987796137 901082374 886493500 867747306 909137856 ...

output:

1644255417664

result:

ok 1 number(s): "1644255417664"

Test #44:

score: 30
Accepted
time: 182ms
memory: 3980kb

input:

1990 1814
884308096 428336395 809952056 988424697 968926806 531693306 804652877 996609936 628832580 756634761 948049502 776388942 891543380 670578485 694810908 618499966 880317657 790908603 898536488 916506346 681111642 743660354 181619630 929311587 694688217 902127580 970327269 828665064 845661937 ...

output:

1615363911472

result:

ok 1 number(s): "1615363911472"

Test #45:

score: 30
Accepted
time: 167ms
memory: 3808kb

input:

1999 643
612475887 910066440 572930568 745481768 888345747 937310737 549535515 892907022 498074183 966597557 419177212 845578771 953301653 978769410 723489919 935499105 699092055 898555711 882561710 808463737 855033221 941298957 914024309 768523668 820754903 925347007 923929056 912228451 986356619 8...

output:

1668088236213

result:

ok 1 number(s): "1668088236213"

Test #46:

score: 30
Accepted
time: 208ms
memory: 3736kb

input:

1990 848
277718378 698756806 808094068 842827032 811883240 469520094 558528948 747769870 881449402 872970156 739279494 960631656 853053706 850130305 599125838 852939527 834773352 819725882 603456375 397985036 277293171 450987742 819001202 846987967 977069016 450929207 874507240 950999831 983181555 9...

output:

1785792859364

result:

ok 1 number(s): "1785792859364"

Test #47:

score: 30
Accepted
time: 207ms
memory: 3808kb

input:

2000 1046
737138364 685760661 584040104 525506876 753688938 259787156 768500846 893340398 985392573 630259364 590568334 736933612 141358297 -350163936 876840049 735395532 493244119 924377302 662900404 616854383 878228570 986713828 900191276 847999029 698596533 479852941 854009565 807378111 872239007...

output:

1665357764010

result:

ok 1 number(s): "1665357764010"

Test #48:

score: 30
Accepted
time: 197ms
memory: 3688kb

input:

1993 414
346474939 862863806 -294092189 268392073 656495340 444579331 60896568 879799612 -694624689 627107206 910420440 908496438 729679006 447913194 -733118666 662428753 315201168 195329053 523437563 -388070214 899429417 220490088 735169078 649444308 961131717 807873079 941788594 988199229 70576820...

output:

1319139012658

result:

ok 1 number(s): "1319139012658"

Test #49:

score: 30
Accepted
time: 192ms
memory: 3676kb

input:

1985 811
-434186608 -109280817 307572083 -244859482 63637186 336209580 331309432 683786241 603996883 446492309 907608037 242030211 204081140 969701447 727635495 -159882211 508628649 56490917 782763126 263526098 488301372 803142876 -215661754 35364782 767148505 619581380 -540391486 84663043 176230644...

output:

721248122867

result:

ok 1 number(s): "721248122867"

Test #50:

score: 30
Accepted
time: 173ms
memory: 3744kb

input:

1981 72
861257128 999690615 611368574 199937368 523825525 298081621 -220186146 590601516 468161289 -171899546 713181450 490757951 830283943 225984256 396857396 -220160944 399438502 544358979 749637347 188683605 717328124 248235904 31486272 29138321 579549183 545414202 821568737 810175041 -219796022 ...

output:

978280843795

result:

ok 1 number(s): "978280843795"

Test #51:

score: 30
Accepted
time: 207ms
memory: 3928kb

input:

1967 414
836965195 364096046 -727892857 630511541 854456911 189795648 723481760 -799365017 179852594 438242319 -907891877 190060178 -195662209 -374450327 374163652 -428696329 -510212123 -869247039 878000902 293917527 -240772514 657415415 -701811534 -599418955 116069837 806442407 421652486 -839709585...

output:

682063918460

result:

ok 1 number(s): "682063918460"

Test #52:

score: 30
Accepted
time: 199ms
memory: 3740kb

input:

1999 485
-247715268 -430131435 -29198496 -919963084 -445632238 -804340162 -733547158 -629490999 -515885607 -692381125 -963351274 152356387 -902211270 -469879401 -130853165 -937438382 -212937045 -998651459 -403350151 -560204441 -723711951 -810729248 -715137009 -901219352 -403833305 -799718550 -985090...

output:

305168246498

result:

ok 1 number(s): "305168246498"

Test #53:

score: 30
Accepted
time: 205ms
memory: 3740kb

input:

1999 1218
-942917756 -316092372 -334791608 -493735909 -153317245 -142208832 -476714117 -870488879 -987913544 -273634916 -517506553 -702448815 -835556773 -362568548 -601563598 -847572843 -629084274 -318641059 -949818880 -910197603 -904727741 -971767448 -702400627 -844005675 -755725074 -958233769 -903...

output:

96718573963

result:

ok 1 number(s): "96718573963"

Test #54:

score: 30
Accepted
time: 201ms
memory: 3988kb

input:

1990 1486
-470045430 210053428 -714182799 -753815710 143806523 -192188051 -944989546 -618602827 -932408198 -92674394 73550900 -50143534 -502673713 477720574 -718490345 -852526022 241820263 -787421281 -947341123 -954556383 -557425487 -556544223 631239598 18865796 -260659919 -909929149 120831006 56549...

output:

20169870109

result:

ok 1 number(s): "20169870109"

Test #55:

score: 30
Accepted
time: 183ms
memory: 3736kb

input:

1992 53
649349116 -268377368 -848083538 -56468593 592860402 434472968 -440995039 689743140 621150496 572387015 -153745521 285379444 634539446 -995741373 -230065021 829764553 714312435 934685369 930196307 601847791 351366773 -659171418 900465512 -285899100 886740219 -337731504 275640829 -36525617 -76...

output:

39475104776

result:

ok 1 number(s): "39475104776"

Test #56:

score: 30
Accepted
time: 181ms
memory: 3712kb

input:

1983 571
-919722778 -690571684 -768199760 -744831768 -825506206 -614870836 -945467893 -748961408 -458322795 -401050089 -921952296 -976719227 -774079066 -725411795 -934426554 -985191787 -851290389 -569246769 -632700615 -789048528 -735859960 -474155864 -948166566 -661473704 -717327254 -759771468 -1918...

output:

524025907896

result:

ok 1 number(s): "524025907896"

Test #57:

score: 30
Accepted
time: 164ms
memory: 3980kb

input:

1999 1117
-532527395 -742137235 -898869303 -729865930 -936562431 -843495594 -966394975 -883001591 -797875109 -887017439 -986802470 -920802150 -961386699 -683186897 -667146485 -822980101 -728481916 -782537470 -995653405 -902996866 -439455441 -816753861 -317078592 -896417484 -878989738 -795846738 -748...

output:

586544605460

result:

ok 1 number(s): "586544605460"

Test #58:

score: 30
Accepted
time: 166ms
memory: 3740kb

input:

1996 1272
-410823591 -265580268 -534602652 -719855756 -506119362 -682436395 -921337475 -484917927 -208113025 -341100538 -690250769 -526951739 -969476546 -643460849 -701244702 -949222246 -669191839 -132549856 -830808707 -665706135 -943798192 -641044068 -816352944 -502631689 20516611 -913788176 -36488...

output:

670066534763

result:

ok 1 number(s): "670066534763"

Test #59:

score: 30
Accepted
time: 205ms
memory: 3808kb

input:

1982 646
-587885815 -969349130 -651269788 -698430646 -783503600 -968468079 -737412762 -996577678 -998891381 -866784619 -517415348 -902986006 -858965695 -938291052 -612359798 -966764685 -650439988 -884329858 -639854295 -547449190 -731854675 -639921717 -708370879 -946277518 -794637336 -980257949 -9330...

output:

208781251

result:

ok 1 number(s): "208781251"

Test #60:

score: 30
Accepted
time: 189ms
memory: 3804kb

input:

1976 81
-906942557 -952155477 -801077039 -769938210 -637141089 -275061912 -917580370 -480738196 -919676650 -758165874 -725306031 -766023600 -768228004 -898040811 -890212041 -897036620 -867153615 -879238015 -892994908 -845654997 -837875837 -517119292 -688681307 -206601018 -861129830 -624167097 -78529...

output:

335215306

result:

ok 1 number(s): "335215306"

Test #61:

score: 30
Accepted
time: 148ms
memory: 3692kb

input:

1999 1094
-951715848 -944024692 -999935303 -955405482 -937225548 -964346427 -954407679 -906075652 -998195073 -978947040 -963923284 -934940456 -952119618 -996344191 -962470704 -944977384 -944479127 -582890715 -913752930 -912446176 -951103299 -948828179 -964480562 -949759189 -988529742 -957299173 -963...

output:

987812599371

result:

ok 1 number(s): "987812599371"

Test #62:

score: 30
Accepted
time: 141ms
memory: 3744kb

input:

1996 1562
-880538785 -732087456 -956112262 -941656429 -980201521 -768925325 -872657137 -986586882 -917440781 -793920801 -933269032 -877160667 -948606930 -954258971 -785493673 -863578433 -982425912 -967520338 -970016038 -924717399 -992970508 -924619743 -862726159 -973310567 -957740648 -993705090 -942...

output:

1168988030619

result:

ok 1 number(s): "1168988030619"

Test #63:

score: 30
Accepted
time: 201ms
memory: 3740kb

input:

1998 177
-891127178 -948397781 -977655896 -928341381 -991806439 -929432406 -914748777 -961573301 -951933995 -748728513 -801970526 -987908743 -936535303 -811945324 -967391904 -959346504 -972168968 -990017468 -725385106 -737839618 -969354021 -951123893 -830863574 -985400397 -975321721 -963957635 -8757...

output:

48896083660

result:

ok 1 number(s): "48896083660"

Test #64:

score: 30
Accepted
time: 192ms
memory: 3780kb

input:

1994 67
-892173484 -969652336 -858299089 -948575776 -890516430 -704627881 -954872472 -939735937 -956813766 -899347751 -892140181 -883522832 -938103287 -823024693 -877232050 -872603348 -980342514 -967325144 -994818729 -991633968 -953675180 -886337453 -910170622 -899176325 -939993732 -951557378 -82159...

output:

761045593

result:

ok 1 number(s): "761045593"

Test #65:

score: 30
Accepted
time: 208ms
memory: 3736kb

input:

2000 1871
-986802933 -881489686 -946510697 -883223843 -913755720 -998257087 -462550760 -885324812 -929160799 -926365342 -903331002 -934295393 -827592518 -841192871 -916531514 -962837858 -970863253 -996908342 -935777198 -994618308 -853662106 -775175464 -967993431 -976712807 -930124182 -929985787 -950...

output:

-421853101

result:

ok 1 number(s): "-421853101"

Test #66:

score: 30
Accepted
time: 129ms
memory: 3688kb

input:

2000 2000
-1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1000000000 -1...

output:

2000000000000

result:

ok 1 number(s): "2000000000000"

Test #67:

score: 30
Accepted
time: 170ms
memory: 3964kb

input:

2000 0
421396092 -420198994 -248060140 208224561 -460473748 464826490 -293926525 -807566884 -996229071 -42049434 504586427 -15293165 170469651 -417962071 574148883 -805686447 -385430283 -429474003 -184196538 -261509772 21519584 -323991355 443223823 -912001390 -356948026 868749206 78904481 156756969 ...

output:

34126413905

result:

ok 1 number(s): "34126413905"

Test #68:

score: 30
Accepted
time: 77ms
memory: 3684kb

input:

1551 2000
-972444077 -983971207 -986752506 -967946586 -983736209 -989739676 -987346466 -990983052 -986544378 -989946229 -999597205 -994924958 -977798234 -984158869 -981064400 -999945502 -994821128 -960235120 -997299033 -994484588 -997045212 -990734141 -976646198 -995393258 -980688728 -999686924 -999...

output:

1533462008807

result:

ok 1 number(s): "1533462008807"

Test #69:

score: 30
Accepted
time: 45ms
memory: 3976kb

input:

1182 2000
-877597156 -924834448 -635220891 -986396713 -954783771 -412237439 -518437672 -683471670 -798403199 -169247323 -801738686 -711142063 -987527745 -620190178 -395668147 -195737491 -947438727 -873779661 -919872535 -746987100 -478691758 -312406840 -426188181 -537869304 -362680304 -264210724 -514...

output:

967358094462

result:

ok 1 number(s): "967358094462"

Test #70:

score: 30
Accepted
time: 79ms
memory: 3708kb

input:

1312 2000
159036736 -333565955 988852293 554082865 627198827 94139215 534202540 607837724 -336112897 -378006797 637490660 305818807 129165648 961068152 983504442 471782579 128853137 -222342656 721771813 648737724 581475208 472234254 833583658 832628113 938963497 -377532416 966658711 796397705 605024...

output:

1260852024931

result:

ok 1 number(s): "1260852024931"

Subtask #3:

score: 0
Time Limit Exceeded

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #71:

score: 0
Time Limit Exceeded

input:

99983 11205
879618051 934034954 893087852 996635460 764445474 834609894 994581688 889879253 898198258 980259160 925585852 867650415 957976554 961113699 869939386 970770805 955998993 994374580 999041860 999445061 993994460 944419530 745932766 962684567 971328213 980457114 983644494 965204567 93148962...

output:


result: