답안 #911248

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
911248 2024-01-18T17:01:08 Z cadmiumsky Fish 2 (JOI22_fish2) C++17
100 / 100
3357 ms 54368 KB
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
using namespace std;
 
using ll = long long;
using ld = long double;
 
//#define int ll
#define sz(x) ((int)(x).size())
 
using pii = pair<int,int>;
using tii = tuple<int,int,int>;
 
const int nmax = 1e5 + 5;
const int inf = 1e9 + 5;
 
template<typename Node> 
struct AINT {
  vector<Node> aint;
  int n;
  void init(int _n, Node TMP = Node()) {
    n = _n;
    aint.assign(2 * n + 5, TMP);
  }
  
  tii getsons(int node, int cl, int cr) { int mid = cl + cr >> 1; return tii{mid, node + 1, node + (mid - cl + 1) * 2};}
  
  template<class CB> void walk(int ismutable, int toRight, CB&& cb) { 
    if(ismutable == 0 && toRight == 0) walk<0, 0>(cb, 1, 1, n); 
    else if(ismutable == 0) walk<0, 1>(cb, 1, 1, n); 
    else if(toRight == 0) walk<1, 0>(cb, 1, 1, n);
    else walk<1, 1>(cb, 1, 1, n);
  }
  template<int ismutable, int toRight, class CB> void walk(CB&& cb, int node, int cl, int cr) { 
    
    //cerr << node << '\t' << cl << ' ' << cr << '\n';
    
    if(!cb(aint[node], cl, cr)) return;
    
    auto [mid, L, R] = getsons(node, cl, cr);
    aint[node].push(aint[L], aint[R]);
    
    if(toRight) walk<ismutable, toRight>(cb, L, cl, mid), walk<ismutable, toRight>(cb, R, mid + 1, cr);
    else walk<ismutable, toRight>(cb, R, mid + 1, cr), walk<ismutable, toRight>(cb, L, cl, mid);
    
    if(ismutable) aint[node].pull(aint[L], aint[R]);
    return;
  }
};
 
struct MinCounter {
  int mn, cnt;
  
  int add;
  
  MinCounter(int a, int b, int c = 0): mn(a), cnt(b), add(c) {;}
  MinCounter(): mn(inf), cnt(0), add(0) {;}
  
  void push(MinCounter& a, MinCounter& b) {
    a.mn += add;
    a.add += add;
    b.add += add;
    b.mn += add;
    
    add = 0;
  }
  
  void pull(const MinCounter a, const MinCounter b) {
    *this = MinCounter(min(a.mn, b.mn), a.cnt * (a.mn <= b.mn) + b.cnt * (b.mn <= a.mn));
  }
};
 
struct GreaterFinder {
  int mx;
  GreaterFinder(int a = 0): mx(a) {;}
  void pull(const GreaterFinder& a, const GreaterFinder& b) { *this = GreaterFinder(max(a.mx, b.mx)); }
  void push(const GreaterFinder& a, const GreaterFinder& b) {;}
};
 
struct Sum {
  ll sum;
  Sum(ll a = 0): sum(a) {;}
  void pull(const Sum& a, const Sum& b) { *this = Sum(a.sum + b.sum); }
  void push(const Sum& a, const Sum& b) {;}
};
 
int a[nmax];
 
AINT<Sum> sum;
 
ll getsum(int l, int r) { 
  ll rez = 0;
  
  //for(int i = l; i <= r; i++)
    //rez += a[i];
  
  sum.walk(0, 1, [&](Sum& a, int cl, int cr) { if(cr < l || r < cl) return 0; if(l <= cl && cr <= r) { rez += a.sum; return 0; } return 1; }); return rez; 
  
  return rez;
}
 
AINT<MinCounter> mncnt;
 
int n;
 
namespace Finders {
  AINT<GreaterFinder> finder;
  
  int nextGreater(int P, ll lim) { // urmatorul de la pozitia P >= lim
    int rez = n + 1;
    finder.walk(0, 1, 
      [&](GreaterFinder& a, int cl, int cr) { if(rez < cl) return 0; if(cr < P || a.mx < lim) { rez = cr + 1; return 0; } if(cl == cr) { rez = cl; return 0; } return 1; });
    return rez;
  }
  
  int prevGreater(int P, ll lim) {
    int rez = 0;
    finder.walk(0, 0, 
      [&](GreaterFinder& a, int cl, int cr) { if(rez > cr) return 0; if(P < cl || a.mx < lim) { rez = cl - 1; return 0; } if(cl == cr) { rez = cl; return 0; } return 1; });
    return rez;
  }
  
  int nextBreaker(int L, int start) {
    int ptr = start;
    while(ptr < n) {
      int essai = nextGreater(ptr + 1, getsum(L, ptr) + 1);
      if(essai == ptr + 1) {
        return ptr + 1;
      }
      ptr = essai - 1;
    }
    return n + 1;
  }
  
  int prevBreaker(int R, int start) {
    int ptr = start;
    while(ptr > 1) {
      int essai = prevGreater(ptr - 1, getsum(ptr, R) + 1);
      if(essai == ptr - 1) {
        return ptr - 1;
      }
      ptr = essai + 1;
    }
    return 0;
  }
}
 
 
vector<pii> getIntervs(int P) {
  
  using namespace Finders;
  vector<pii> elems;
  
  
  
  int L = P, R = P, direction = 1, fail = 0;
  while(L > 1 || R < n) {
    if(direction == 1) {
      int nvR = nextBreaker(L, R) - 1;
      if(nvR == R && fail) {
        elems.emplace_back(L, R);
        if((L != 1 && a[L - 1] <= a[R + 1]) || R == n) L--;
        else R++;
        fail = 0;
      }
      else { fail = R == nvR; R = nvR; }
    }
    
    else {
      int nvL = prevBreaker(R, L) + 1;
      if(nvL == L && fail) {
        elems.emplace_back(L, R);
        if((L != 1 && a[L - 1] <= a[R + 1]) || R == n) L--;
        else R++;
        fail = 0;
      }
      else {fail = L == nvL; L = nvL; }
    }
    
    direction *= -1;
  }
  
  return elems;
}
 
 
namespace Segments {
  unordered_set<int> rightends[nmax];
  unordered_set<int> leftends[nmax];
  
  void erase(int l, int r) {
    if(leftends[l].count(r)) {
      leftends[l].erase(r);
      rightends[r].erase(l);
      
      mncnt.walk(1, 1, [&](MinCounter& val, int cl, int cr) {
        if(cr < l || r < cl) return 0;
        if(l <= cl && cr <= r) {
          val.mn -= 1;
          val.add -= 1;
          return 0;
        }
        return 1;
      });
    }
    return;
  }
  
  void insert(int l, int r) {
    if(!leftends[l].count(r)) {
      leftends[l].insert(r);
      rightends[r].insert(l);
      
      mncnt.walk(1, 1, [&](MinCounter& val, int cl, int cr) {
        if(cr < l || r < cl) return 0;
        if(l <= cl && cr <= r) {
          val.mn += 1;
          val.add += 1;
          return 0;
        }
        return 1;
      });
    }
    return;
  }
}
 
void updPoz(int P, int x) {
  
  vector<pii> V = getIntervs(P), T;
  V.reserve(60);
  if(P > 1) for(auto x : Segments::rightends[P - 1]) V.emplace_back(x, P - 1);
  if(P < n) for(auto x : Segments::leftends[P + 1]) V.emplace_back(P + 1, x);
  
  for(auto [l, r] : V)
    Segments::erase(l, r);
  
  Finders::finder.walk(1, 1, [&](GreaterFinder& val, int cl, int cr) {
    if(cr < P || P < cl) return 0;
    if(cl == cr) {
      val = GreaterFinder(x);
      return 0;
    } 
    return 1;
  });
  
  a[P] = x;
  
  sum.walk(1, 1, [&](Sum& val, int cl, int cr) {
    if(cr < P || P < cl) return 0;
    if(cl == cr) {
      val = Sum(x);
      return 0;
    } 
    return 1;
  });
  
  V = getIntervs(P);
  if(P > 1) T = getIntervs(P - 1), copy(all(T), back_inserter(V));
  if(P < n) T = getIntervs(P + 1), copy(all(T), back_inserter(V));
 
  for(auto [l, r] : V)
    Segments::insert(l, r);
    
  return;
}
 
int query(int l, int r) {
  int answer = l, ptr = l;
  while(ptr <= r) {
    ptr = Finders::nextBreaker(l, ptr);
    if(ptr <= r) answer = ptr;
  }
  
  l = answer;
  
  answer = ptr = r;
  while(ptr >= l) {
    ptr = Finders::prevBreaker(r, ptr);
    if(ptr >= l) answer = ptr;
  }
  
  r = answer;
  
  MinCounter cnt(1e9 + 5, -1, 0), cnt2;
  
  mncnt.walk(0, 1, [&](MinCounter& val, int cl, int cr) {
    if(cr < l || r < cl) return 0;
    if(l <= cl && cr <= r) {
      cnt.pull(cnt, val);
      return 0;
    }
    return 1;
  });
  
  return cnt.cnt;
}
 
 
signed main() {
  cin >> n;
  for(int i = 1; i <= n; i++) {
    cin >> a[i];
  }
  
  using namespace Finders;
  
  finder.init(n);
  mncnt.init(n);
  sum.init(n);
  
  finder.walk(1, 1, [&](GreaterFinder& val, int cl, int cr) { if(cl != cr) return 1; val = GreaterFinder(a[cl]); return 0;});
  mncnt.walk(1, 1, [&](MinCounter& val, int cl, int cr) { if(cl != cr) return 1; val = MinCounter(0, 1); return 0;});
  sum.walk(1, 1, [&](Sum& val, int cl, int cr) { if(cl != cr) return 1; val = Sum(a[cl]); return 0;});
  
  vector<pii> V, T;
  for(int i = 1; i <= n; i++) {
    T = getIntervs(i);
    copy(all(T), back_inserter(V));
  }
  
  for(auto [l, r] : V) {
    Segments::insert(l, r);
  }
  
  int q;
  cin >> q;
  for(int TC = 0, t, x, y; TC < q; TC++) {
    cin >> t >> x >> y;
    if(t == 1)
      updPoz(x, y);
    else
      cout << query(x, y) << '\n';
  }
}
 
/**
      Anul asta se da centroid.
-- Surse oficiale
*/

Compilation message

fish2.cpp: In instantiation of 'tii AINT<Node>::getsons(int, int, int) [with Node = Sum; tii = std::tuple<int, int, int>]':
fish2.cpp:41:24:   required from 'void AINT<Node>::walk(CB&&, int, int, int) [with int ismutable = 0; int toRight = 0; CB = getsum(int, int)::<lambda(Sum&, int, int)>&; Node = Sum]'
fish2.cpp:30:50:   required from 'void AINT<Node>::walk(int, int, CB&&) [with CB = getsum(int, int)::<lambda(Sum&, int, int)>; Node = Sum]'
fish2.cpp:98:141:   required from here
fish2.cpp:27:56: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   27 |   tii getsons(int node, int cl, int cr) { int mid = cl + cr >> 1; return tii{mid, node + 1, node + (mid - cl + 1) * 2};}
      |                                                     ~~~^~~~
fish2.cpp: In instantiation of 'tii AINT<Node>::getsons(int, int, int) [with Node = GreaterFinder; tii = std::tuple<int, int, int>]':
fish2.cpp:41:24:   required from 'void AINT<Node>::walk(CB&&, int, int, int) [with int ismutable = 0; int toRight = 0; CB = Finders::nextGreater(int, ll)::<lambda(GreaterFinder&, int, int)>&; Node = GreaterFinder]'
fish2.cpp:30:50:   required from 'void AINT<Node>::walk(int, int, CB&&) [with CB = Finders::nextGreater(int, ll)::<lambda(GreaterFinder&, int, int)>; Node = GreaterFinder]'
fish2.cpp:113:171:   required from here
fish2.cpp:27:56: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
fish2.cpp: In instantiation of 'tii AINT<Node>::getsons(int, int, int) [with Node = MinCounter; tii = std::tuple<int, int, int>]':
fish2.cpp:41:24:   required from 'void AINT<Node>::walk(CB&&, int, int, int) [with int ismutable = 0; int toRight = 0; CB = Segments::erase(int, int)::<lambda(MinCounter&, int, int)>&; Node = MinCounter]'
fish2.cpp:30:50:   required from 'void AINT<Node>::walk(int, int, CB&&) [with CB = Segments::erase(int, int)::<lambda(MinCounter&, int, int)>; Node = MinCounter]'
fish2.cpp:205:8:   required from here
fish2.cpp:27:56: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 11352 KB Output is correct
2 Correct 4 ms 11356 KB Output is correct
3 Correct 4 ms 11356 KB Output is correct
4 Correct 4 ms 11356 KB Output is correct
5 Correct 12 ms 11356 KB Output is correct
6 Correct 9 ms 11452 KB Output is correct
7 Correct 12 ms 11448 KB Output is correct
8 Correct 11 ms 11352 KB Output is correct
9 Correct 10 ms 11612 KB Output is correct
10 Correct 6 ms 11356 KB Output is correct
11 Correct 6 ms 11352 KB Output is correct
12 Correct 10 ms 11356 KB Output is correct
13 Correct 10 ms 11356 KB Output is correct
14 Correct 8 ms 11512 KB Output is correct
15 Correct 12 ms 11608 KB Output is correct
16 Correct 8 ms 11608 KB Output is correct
17 Correct 8 ms 11352 KB Output is correct
18 Correct 7 ms 11428 KB Output is correct
19 Correct 7 ms 11356 KB Output is correct
20 Correct 7 ms 11356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 11356 KB Output is correct
2 Correct 624 ms 42336 KB Output is correct
3 Correct 1006 ms 44168 KB Output is correct
4 Correct 628 ms 43436 KB Output is correct
5 Correct 1024 ms 45268 KB Output is correct
6 Correct 135 ms 27844 KB Output is correct
7 Correct 547 ms 26848 KB Output is correct
8 Correct 134 ms 28004 KB Output is correct
9 Correct 558 ms 27064 KB Output is correct
10 Correct 766 ms 33896 KB Output is correct
11 Correct 1103 ms 36832 KB Output is correct
12 Correct 250 ms 28016 KB Output is correct
13 Correct 291 ms 28192 KB Output is correct
14 Correct 221 ms 32532 KB Output is correct
15 Correct 216 ms 31496 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 11352 KB Output is correct
2 Correct 4 ms 11356 KB Output is correct
3 Correct 4 ms 11356 KB Output is correct
4 Correct 4 ms 11356 KB Output is correct
5 Correct 12 ms 11356 KB Output is correct
6 Correct 9 ms 11452 KB Output is correct
7 Correct 12 ms 11448 KB Output is correct
8 Correct 11 ms 11352 KB Output is correct
9 Correct 10 ms 11612 KB Output is correct
10 Correct 6 ms 11356 KB Output is correct
11 Correct 6 ms 11352 KB Output is correct
12 Correct 10 ms 11356 KB Output is correct
13 Correct 10 ms 11356 KB Output is correct
14 Correct 8 ms 11512 KB Output is correct
15 Correct 12 ms 11608 KB Output is correct
16 Correct 8 ms 11608 KB Output is correct
17 Correct 8 ms 11352 KB Output is correct
18 Correct 7 ms 11428 KB Output is correct
19 Correct 7 ms 11356 KB Output is correct
20 Correct 7 ms 11356 KB Output is correct
21 Correct 4 ms 11356 KB Output is correct
22 Correct 624 ms 42336 KB Output is correct
23 Correct 1006 ms 44168 KB Output is correct
24 Correct 628 ms 43436 KB Output is correct
25 Correct 1024 ms 45268 KB Output is correct
26 Correct 135 ms 27844 KB Output is correct
27 Correct 547 ms 26848 KB Output is correct
28 Correct 134 ms 28004 KB Output is correct
29 Correct 558 ms 27064 KB Output is correct
30 Correct 766 ms 33896 KB Output is correct
31 Correct 1103 ms 36832 KB Output is correct
32 Correct 250 ms 28016 KB Output is correct
33 Correct 291 ms 28192 KB Output is correct
34 Correct 221 ms 32532 KB Output is correct
35 Correct 216 ms 31496 KB Output is correct
36 Correct 649 ms 46000 KB Output is correct
37 Correct 1014 ms 46008 KB Output is correct
38 Correct 971 ms 41168 KB Output is correct
39 Correct 637 ms 47212 KB Output is correct
40 Correct 973 ms 41536 KB Output is correct
41 Correct 140 ms 27888 KB Output is correct
42 Correct 146 ms 27852 KB Output is correct
43 Correct 546 ms 27072 KB Output is correct
44 Correct 588 ms 26524 KB Output is correct
45 Correct 851 ms 36828 KB Output is correct
46 Correct 772 ms 34240 KB Output is correct
47 Correct 933 ms 29364 KB Output is correct
48 Correct 282 ms 28712 KB Output is correct
49 Correct 257 ms 28184 KB Output is correct
50 Correct 208 ms 32456 KB Output is correct
51 Correct 210 ms 31592 KB Output is correct
52 Correct 204 ms 32444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 11356 KB Output is correct
2 Correct 624 ms 42336 KB Output is correct
3 Correct 1006 ms 44168 KB Output is correct
4 Correct 628 ms 43436 KB Output is correct
5 Correct 1024 ms 45268 KB Output is correct
6 Correct 135 ms 27844 KB Output is correct
7 Correct 547 ms 26848 KB Output is correct
8 Correct 134 ms 28004 KB Output is correct
9 Correct 558 ms 27064 KB Output is correct
10 Correct 766 ms 33896 KB Output is correct
11 Correct 1103 ms 36832 KB Output is correct
12 Correct 250 ms 28016 KB Output is correct
13 Correct 291 ms 28192 KB Output is correct
14 Correct 221 ms 32532 KB Output is correct
15 Correct 216 ms 31496 KB Output is correct
16 Correct 5 ms 11356 KB Output is correct
17 Correct 1748 ms 44572 KB Output is correct
18 Correct 1221 ms 46188 KB Output is correct
19 Correct 1737 ms 45476 KB Output is correct
20 Correct 1865 ms 47684 KB Output is correct
21 Correct 1726 ms 44916 KB Output is correct
22 Correct 1208 ms 47624 KB Output is correct
23 Correct 1695 ms 44508 KB Output is correct
24 Correct 1875 ms 46992 KB Output is correct
25 Correct 1727 ms 45780 KB Output is correct
26 Correct 1959 ms 48260 KB Output is correct
27 Correct 454 ms 28364 KB Output is correct
28 Correct 467 ms 28652 KB Output is correct
29 Correct 466 ms 28872 KB Output is correct
30 Correct 1317 ms 29364 KB Output is correct
31 Correct 1470 ms 29764 KB Output is correct
32 Correct 2082 ms 38212 KB Output is correct
33 Correct 1212 ms 35256 KB Output is correct
34 Correct 2158 ms 36236 KB Output is correct
35 Correct 1671 ms 31476 KB Output is correct
36 Correct 1515 ms 36792 KB Output is correct
37 Correct 713 ms 28480 KB Output is correct
38 Correct 686 ms 28456 KB Output is correct
39 Correct 595 ms 33272 KB Output is correct
40 Correct 614 ms 32132 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 11356 KB Output is correct
2 Correct 624 ms 42336 KB Output is correct
3 Correct 1006 ms 44168 KB Output is correct
4 Correct 628 ms 43436 KB Output is correct
5 Correct 1024 ms 45268 KB Output is correct
6 Correct 135 ms 27844 KB Output is correct
7 Correct 547 ms 26848 KB Output is correct
8 Correct 134 ms 28004 KB Output is correct
9 Correct 558 ms 27064 KB Output is correct
10 Correct 766 ms 33896 KB Output is correct
11 Correct 1103 ms 36832 KB Output is correct
12 Correct 250 ms 28016 KB Output is correct
13 Correct 291 ms 28192 KB Output is correct
14 Correct 221 ms 32532 KB Output is correct
15 Correct 216 ms 31496 KB Output is correct
16 Correct 4 ms 11608 KB Output is correct
17 Correct 2715 ms 44580 KB Output is correct
18 Correct 2320 ms 54108 KB Output is correct
19 Correct 2746 ms 45248 KB Output is correct
20 Correct 2190 ms 51280 KB Output is correct
21 Correct 3029 ms 44788 KB Output is correct
22 Correct 2332 ms 53044 KB Output is correct
23 Correct 3153 ms 46968 KB Output is correct
24 Correct 2337 ms 52892 KB Output is correct
25 Correct 2876 ms 44840 KB Output is correct
26 Correct 681 ms 32116 KB Output is correct
27 Correct 731 ms 33328 KB Output is correct
28 Correct 1576 ms 38176 KB Output is correct
29 Correct 686 ms 32416 KB Output is correct
30 Correct 733 ms 33260 KB Output is correct
31 Correct 1715 ms 39600 KB Output is correct
32 Correct 2406 ms 46768 KB Output is correct
33 Correct 1880 ms 34648 KB Output is correct
34 Correct 1967 ms 44684 KB Output is correct
35 Correct 1481 ms 33460 KB Output is correct
36 Correct 2208 ms 44716 KB Output is correct
37 Correct 1429 ms 34324 KB Output is correct
38 Correct 1096 ms 32784 KB Output is correct
39 Correct 887 ms 35808 KB Output is correct
40 Correct 632 ms 34088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 11352 KB Output is correct
2 Correct 4 ms 11356 KB Output is correct
3 Correct 4 ms 11356 KB Output is correct
4 Correct 4 ms 11356 KB Output is correct
5 Correct 12 ms 11356 KB Output is correct
6 Correct 9 ms 11452 KB Output is correct
7 Correct 12 ms 11448 KB Output is correct
8 Correct 11 ms 11352 KB Output is correct
9 Correct 10 ms 11612 KB Output is correct
10 Correct 6 ms 11356 KB Output is correct
11 Correct 6 ms 11352 KB Output is correct
12 Correct 10 ms 11356 KB Output is correct
13 Correct 10 ms 11356 KB Output is correct
14 Correct 8 ms 11512 KB Output is correct
15 Correct 12 ms 11608 KB Output is correct
16 Correct 8 ms 11608 KB Output is correct
17 Correct 8 ms 11352 KB Output is correct
18 Correct 7 ms 11428 KB Output is correct
19 Correct 7 ms 11356 KB Output is correct
20 Correct 7 ms 11356 KB Output is correct
21 Correct 4 ms 11356 KB Output is correct
22 Correct 624 ms 42336 KB Output is correct
23 Correct 1006 ms 44168 KB Output is correct
24 Correct 628 ms 43436 KB Output is correct
25 Correct 1024 ms 45268 KB Output is correct
26 Correct 135 ms 27844 KB Output is correct
27 Correct 547 ms 26848 KB Output is correct
28 Correct 134 ms 28004 KB Output is correct
29 Correct 558 ms 27064 KB Output is correct
30 Correct 766 ms 33896 KB Output is correct
31 Correct 1103 ms 36832 KB Output is correct
32 Correct 250 ms 28016 KB Output is correct
33 Correct 291 ms 28192 KB Output is correct
34 Correct 221 ms 32532 KB Output is correct
35 Correct 216 ms 31496 KB Output is correct
36 Correct 649 ms 46000 KB Output is correct
37 Correct 1014 ms 46008 KB Output is correct
38 Correct 971 ms 41168 KB Output is correct
39 Correct 637 ms 47212 KB Output is correct
40 Correct 973 ms 41536 KB Output is correct
41 Correct 140 ms 27888 KB Output is correct
42 Correct 146 ms 27852 KB Output is correct
43 Correct 546 ms 27072 KB Output is correct
44 Correct 588 ms 26524 KB Output is correct
45 Correct 851 ms 36828 KB Output is correct
46 Correct 772 ms 34240 KB Output is correct
47 Correct 933 ms 29364 KB Output is correct
48 Correct 282 ms 28712 KB Output is correct
49 Correct 257 ms 28184 KB Output is correct
50 Correct 208 ms 32456 KB Output is correct
51 Correct 210 ms 31592 KB Output is correct
52 Correct 204 ms 32444 KB Output is correct
53 Correct 5 ms 11356 KB Output is correct
54 Correct 1748 ms 44572 KB Output is correct
55 Correct 1221 ms 46188 KB Output is correct
56 Correct 1737 ms 45476 KB Output is correct
57 Correct 1865 ms 47684 KB Output is correct
58 Correct 1726 ms 44916 KB Output is correct
59 Correct 1208 ms 47624 KB Output is correct
60 Correct 1695 ms 44508 KB Output is correct
61 Correct 1875 ms 46992 KB Output is correct
62 Correct 1727 ms 45780 KB Output is correct
63 Correct 1959 ms 48260 KB Output is correct
64 Correct 454 ms 28364 KB Output is correct
65 Correct 467 ms 28652 KB Output is correct
66 Correct 466 ms 28872 KB Output is correct
67 Correct 1317 ms 29364 KB Output is correct
68 Correct 1470 ms 29764 KB Output is correct
69 Correct 2082 ms 38212 KB Output is correct
70 Correct 1212 ms 35256 KB Output is correct
71 Correct 2158 ms 36236 KB Output is correct
72 Correct 1671 ms 31476 KB Output is correct
73 Correct 1515 ms 36792 KB Output is correct
74 Correct 713 ms 28480 KB Output is correct
75 Correct 686 ms 28456 KB Output is correct
76 Correct 595 ms 33272 KB Output is correct
77 Correct 614 ms 32132 KB Output is correct
78 Correct 4 ms 11608 KB Output is correct
79 Correct 2715 ms 44580 KB Output is correct
80 Correct 2320 ms 54108 KB Output is correct
81 Correct 2746 ms 45248 KB Output is correct
82 Correct 2190 ms 51280 KB Output is correct
83 Correct 3029 ms 44788 KB Output is correct
84 Correct 2332 ms 53044 KB Output is correct
85 Correct 3153 ms 46968 KB Output is correct
86 Correct 2337 ms 52892 KB Output is correct
87 Correct 2876 ms 44840 KB Output is correct
88 Correct 681 ms 32116 KB Output is correct
89 Correct 731 ms 33328 KB Output is correct
90 Correct 1576 ms 38176 KB Output is correct
91 Correct 686 ms 32416 KB Output is correct
92 Correct 733 ms 33260 KB Output is correct
93 Correct 1715 ms 39600 KB Output is correct
94 Correct 2406 ms 46768 KB Output is correct
95 Correct 1880 ms 34648 KB Output is correct
96 Correct 1967 ms 44684 KB Output is correct
97 Correct 1481 ms 33460 KB Output is correct
98 Correct 2208 ms 44716 KB Output is correct
99 Correct 1429 ms 34324 KB Output is correct
100 Correct 1096 ms 32784 KB Output is correct
101 Correct 887 ms 35808 KB Output is correct
102 Correct 632 ms 34088 KB Output is correct
103 Correct 3170 ms 43904 KB Output is correct
104 Correct 1901 ms 52164 KB Output is correct
105 Correct 2028 ms 47544 KB Output is correct
106 Correct 1840 ms 48752 KB Output is correct
107 Correct 3357 ms 45912 KB Output is correct
108 Correct 1847 ms 54368 KB Output is correct
109 Correct 2330 ms 47764 KB Output is correct
110 Correct 2033 ms 52716 KB Output is correct
111 Correct 2032 ms 48364 KB Output is correct
112 Correct 1850 ms 50912 KB Output is correct
113 Correct 693 ms 35064 KB Output is correct
114 Correct 505 ms 31712 KB Output is correct
115 Correct 1705 ms 39592 KB Output is correct
116 Correct 1440 ms 37224 KB Output is correct
117 Correct 540 ms 32324 KB Output is correct
118 Correct 1442 ms 34644 KB Output is correct
119 Correct 759 ms 36036 KB Output is correct
120 Correct 1679 ms 41240 KB Output is correct
121 Correct 1447 ms 37116 KB Output is correct
122 Correct 2323 ms 47136 KB Output is correct
123 Correct 1854 ms 33696 KB Output is correct
124 Correct 1956 ms 41192 KB Output is correct
125 Correct 1711 ms 32520 KB Output is correct
126 Correct 1920 ms 39536 KB Output is correct
127 Correct 1514 ms 36188 KB Output is correct
128 Correct 875 ms 31524 KB Output is correct
129 Correct 929 ms 37964 KB Output is correct
130 Correct 700 ms 35524 KB Output is correct