Submission #911232

# Submission time Handle Problem Language Result Execution time Memory
911232 2024-01-18T16:33:08 Z cadmiumsky Fish 2 (JOI22_fish2) C++17
48 / 100
4000 ms 45640 KB
#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, int lim) { // urmatorul de la pozitia P >= lim
    
    //for(int i = P; i <= n; i++)
      //if(a[i] >= lim) return i;
    //return n + 1;
    
    
    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, int lim) {
    
    
    //for(int i = P; i > 0; i--)
      //if(a[i] >= lim) return i;
    //return 0;
    
    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) {
      if(getsum(L, ptr) < a[ptr + 1]) {
        return ptr + 1;
      }
      ptr = nextGreater(ptr + 1, a[ptr + 1] * 2) - 1;
    }
    return n + 1;
  }
  
  int prevBreaker(int R, int start) {
    int ptr = start;
    while(ptr > 1) {
      if(getsum(ptr, R) < a[ptr - 1]) {
        return ptr - 1;
      }
      ptr = prevGreater(ptr - 1, a[ptr - 1] * 2) + 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) {
    //cerr << L << ' ' << R << '\n';
    if(direction == 1) {
      int nvR = nextBreaker(L, R) - 1;
      //cerr << nvR << '\n';
      if(nvR == R && fail) {
        elems.emplace_back(L, R);
        //cerr << L << ' ' << R << '\n';
        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;
      //cerr << nvL << '\n';
      if(nvL == L && fail) {
        //cerr << L << ' ' << R << '\n';
        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;
  }

  //cerr << "---\ncu vectorul:\n";
  //for(int i = 1; i <= n; i++) cerr << a[i] << ' '; cerr << '\n';
  //cerr << P << " apartine urmatoarelor segmente:\n";
  //for(auto [l, r] : elems)
    //cerr << l << ", " << r << '\n';
  //cerr << "----\n";
  
  //cerr << "----\n";
  
  return elems;
}


namespace Segments {
  set<pii> appearingIntervs;
  
  void erase(int l, int r) {
    if(appearingIntervs.count(pii{l, r})) {
      appearingIntervs.erase(pii{l, r});
      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(!appearingIntervs.count(pii{l, r})) {
      appearingIntervs.insert(pii{l, r});
      
      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) {
  //cerr << "=====\n";
  //cerr << "=====\n";
  //cerr << "=====\n";
  
  vector<pii> V = getIntervs(P), T;
  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(int i = 1; i <= n; i++)
    //cerr << a[i] << ' ';
  //cerr << '\n';
  //cerr << P << " --> " << x << '\n';
  
  //for(auto [l, r] : Segments::appearingIntervs) cerr << l << ", " << r << '\n';
  
  //cerr << "stergem\n";
  
  for(auto [l, r] : V)
    //cerr << l << ' ' << r << '\n',
    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(int i = 1; i <= n; i++)
    //cerr << a[i] << ' ';
  //cerr << '\n';
  //cerr << "inseram\n";
 
  for(auto [l, r] : V)
    //cerr << l << ' ' << r << '\n',
    Segments::insert(l, r);
    
  return;
}

int query(int l, int r) {
  
  //cerr << "----\n";
  
  //cerr << l << ' ' << r << '\n';
  //for(int i = l; i <= r; i++)
    //cerr << a[i] << ' ';
  //cerr << '\n';
  
  //for(auto [l, r] : Segments::appearingIntervs) cerr << l << ' ' << r << '\n';
  
  int answer = l, ptr = l;
  while(ptr <= r) {
    ptr = Finders::nextBreaker(l, ptr);
    if(ptr <= r) answer = ptr;
    //ptr = Finders::nextGreater(ptr, a[ptr] + 1);
  }
  
  l = answer;
  
  answer = ptr = r;
  while(ptr >= l) {
    //cerr << ptr << " --> ";
    ptr = Finders::prevBreaker(r, ptr);
    //cerr << ptr << '\n';
    if(ptr >= l) answer = ptr;
    //ptr = Finders::prevGreater(ptr, a[ptr] + 1);
  }
  
  r = answer;
  
  //cerr << "morph to " << l << ' ' << r << '\n';
  
  MinCounter cnt(1e9 + 5, -1, 0);
  
  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);
  
  //cerr << "initializam si noi?..";
  
  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;});
  
  //cerr << "sau hmphhphph\n";
  
  vector<pii> V, T;
  for(int i = 1; i <= n; i++) {
    T = getIntervs(i);
    copy(all(T), back_inserter(V));
  }
  
  //cerr << "Ai fi crezut ca dupa 89 ne-am fi potolit\n";
  
  for(auto [l, r] : V) {
    Segments::insert(l, r);
  }
  
  //cerr << "Mai bine de atat\n";
  
  int q;
  cin >> q;
  for(int TC = 0, t, x, y; TC < q; TC++) {
    //cerr << "o data\n";
    cin >> t >> x >> y;
    if(t == 1)
      updPoz(x, y);
    else
      cout << query(x, y) << '\n';
    //cerr << "de doua ori data\n\n";
  }
}

/**
      Anul asta se da centroid.
-- Surse oficiale
*/

Compilation message

fish2.cpp: In instantiation of 'tii AINT<Node>::getsons(ll, ll, ll) [with Node = Sum; tii = std::tuple<long long int, long long int, long long int>; ll = long long int]':
fish2.cpp:40:24:   required from 'void AINT<Node>::walk(CB&&, ll, ll, ll) [with long long int ismutable = 0; long long int toRight = 0; CB = getsum(ll, ll)::<lambda(Sum&, ll, ll)>&; Node = Sum; ll = long long int]'
fish2.cpp:29:50:   required from 'void AINT<Node>::walk(ll, ll, CB&&) [with CB = getsum(ll, ll)::<lambda(Sum&, ll, ll)>; Node = Sum; ll = long long int]'
fish2.cpp:97:141:   required from here
fish2.cpp:26:56: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   26 |   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(ll, ll, ll) [with Node = GreaterFinder; tii = std::tuple<long long int, long long int, long long int>; ll = long long int]':
fish2.cpp:40:24:   required from 'void AINT<Node>::walk(CB&&, ll, ll, ll) [with long long int ismutable = 0; long long int toRight = 0; CB = Finders::nextGreater(ll, ll)::<lambda(GreaterFinder&, ll, ll)>&; Node = GreaterFinder; ll = long long int]'
fish2.cpp:29:50:   required from 'void AINT<Node>::walk(ll, ll, CB&&) [with CB = Finders::nextGreater(ll, ll)::<lambda(GreaterFinder&, ll, ll)>; Node = GreaterFinder; ll = long long int]'
fish2.cpp:118:171:   required from here
fish2.cpp:26:56: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
fish2.cpp: In instantiation of 'tii AINT<Node>::getsons(ll, ll, ll) [with Node = MinCounter; tii = std::tuple<long long int, long long int, long long int>; ll = long long int]':
fish2.cpp:40:24:   required from 'void AINT<Node>::walk(CB&&, ll, ll, ll) [with long long int ismutable = 0; long long int toRight = 0; CB = Segments::erase(ll, ll)::<lambda(MinCounter&, ll, ll)>&; Node = MinCounter; ll = long long int]'
fish2.cpp:29:50:   required from 'void AINT<Node>::walk(ll, ll, CB&&) [with CB = Segments::erase(ll, ll)::<lambda(MinCounter&, ll, ll)>; Node = MinCounter; ll = long long int]'
fish2.cpp:225:8:   required from here
fish2.cpp:26:56: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 13 ms 604 KB Output is correct
6 Correct 8 ms 604 KB Output is correct
7 Correct 14 ms 604 KB Output is correct
8 Correct 13 ms 600 KB Output is correct
9 Correct 9 ms 860 KB Output is correct
10 Correct 3 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 8 ms 604 KB Output is correct
13 Correct 6 ms 604 KB Output is correct
14 Correct 5 ms 600 KB Output is correct
15 Correct 7 ms 604 KB Output is correct
16 Correct 5 ms 604 KB Output is correct
17 Correct 5 ms 344 KB Output is correct
18 Correct 3 ms 348 KB Output is correct
19 Correct 4 ms 348 KB Output is correct
20 Correct 3 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 544 KB Output is correct
2 Correct 655 ms 42960 KB Output is correct
3 Correct 1363 ms 42668 KB Output is correct
4 Correct 510 ms 42664 KB Output is correct
5 Correct 1181 ms 42480 KB Output is correct
6 Correct 129 ms 12484 KB Output is correct
7 Correct 927 ms 18148 KB Output is correct
8 Correct 112 ms 13508 KB Output is correct
9 Correct 967 ms 19636 KB Output is correct
10 Correct 571 ms 27344 KB Output is correct
11 Correct 861 ms 42896 KB Output is correct
12 Correct 229 ms 14356 KB Output is correct
13 Correct 263 ms 14784 KB Output is correct
14 Correct 197 ms 15616 KB Output is correct
15 Correct 202 ms 15756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 13 ms 604 KB Output is correct
6 Correct 8 ms 604 KB Output is correct
7 Correct 14 ms 604 KB Output is correct
8 Correct 13 ms 600 KB Output is correct
9 Correct 9 ms 860 KB Output is correct
10 Correct 3 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 8 ms 604 KB Output is correct
13 Correct 6 ms 604 KB Output is correct
14 Correct 5 ms 600 KB Output is correct
15 Correct 7 ms 604 KB Output is correct
16 Correct 5 ms 604 KB Output is correct
17 Correct 5 ms 344 KB Output is correct
18 Correct 3 ms 348 KB Output is correct
19 Correct 4 ms 348 KB Output is correct
20 Correct 3 ms 348 KB Output is correct
21 Correct 1 ms 544 KB Output is correct
22 Correct 655 ms 42960 KB Output is correct
23 Correct 1363 ms 42668 KB Output is correct
24 Correct 510 ms 42664 KB Output is correct
25 Correct 1181 ms 42480 KB Output is correct
26 Correct 129 ms 12484 KB Output is correct
27 Correct 927 ms 18148 KB Output is correct
28 Correct 112 ms 13508 KB Output is correct
29 Correct 967 ms 19636 KB Output is correct
30 Correct 571 ms 27344 KB Output is correct
31 Correct 861 ms 42896 KB Output is correct
32 Correct 229 ms 14356 KB Output is correct
33 Correct 263 ms 14784 KB Output is correct
34 Correct 197 ms 15616 KB Output is correct
35 Correct 202 ms 15756 KB Output is correct
36 Correct 554 ms 42668 KB Output is correct
37 Correct 1425 ms 43604 KB Output is correct
38 Correct 1251 ms 42772 KB Output is correct
39 Correct 609 ms 44340 KB Output is correct
40 Correct 1126 ms 43180 KB Output is correct
41 Correct 126 ms 13764 KB Output is correct
42 Correct 118 ms 13508 KB Output is correct
43 Correct 973 ms 19380 KB Output is correct
44 Correct 1000 ms 18336 KB Output is correct
45 Correct 660 ms 27496 KB Output is correct
46 Correct 593 ms 26516 KB Output is correct
47 Correct 731 ms 25980 KB Output is correct
48 Correct 269 ms 15660 KB Output is correct
49 Correct 271 ms 15292 KB Output is correct
50 Correct 211 ms 15552 KB Output is correct
51 Correct 206 ms 15812 KB Output is correct
52 Correct 200 ms 15640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 544 KB Output is correct
2 Correct 655 ms 42960 KB Output is correct
3 Correct 1363 ms 42668 KB Output is correct
4 Correct 510 ms 42664 KB Output is correct
5 Correct 1181 ms 42480 KB Output is correct
6 Correct 129 ms 12484 KB Output is correct
7 Correct 927 ms 18148 KB Output is correct
8 Correct 112 ms 13508 KB Output is correct
9 Correct 967 ms 19636 KB Output is correct
10 Correct 571 ms 27344 KB Output is correct
11 Correct 861 ms 42896 KB Output is correct
12 Correct 229 ms 14356 KB Output is correct
13 Correct 263 ms 14784 KB Output is correct
14 Correct 197 ms 15616 KB Output is correct
15 Correct 202 ms 15756 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 3457 ms 44204 KB Output is correct
18 Correct 1581 ms 44456 KB Output is correct
19 Correct 3029 ms 43964 KB Output is correct
20 Correct 3226 ms 44080 KB Output is correct
21 Correct 2687 ms 44188 KB Output is correct
22 Correct 1595 ms 43472 KB Output is correct
23 Correct 2671 ms 42572 KB Output is correct
24 Correct 3036 ms 45196 KB Output is correct
25 Correct 2783 ms 42924 KB Output is correct
26 Correct 3043 ms 43768 KB Output is correct
27 Correct 446 ms 15556 KB Output is correct
28 Correct 460 ms 15564 KB Output is correct
29 Correct 434 ms 15300 KB Output is correct
30 Correct 2496 ms 26044 KB Output is correct
31 Correct 2753 ms 27628 KB Output is correct
32 Correct 1769 ms 44548 KB Output is correct
33 Correct 1053 ms 26404 KB Output is correct
34 Correct 1761 ms 42668 KB Output is correct
35 Correct 1410 ms 28588 KB Output is correct
36 Correct 1211 ms 28968 KB Output is correct
37 Correct 732 ms 16572 KB Output is correct
38 Correct 692 ms 16572 KB Output is correct
39 Correct 683 ms 17880 KB Output is correct
40 Correct 638 ms 17604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 544 KB Output is correct
2 Correct 655 ms 42960 KB Output is correct
3 Correct 1363 ms 42668 KB Output is correct
4 Correct 510 ms 42664 KB Output is correct
5 Correct 1181 ms 42480 KB Output is correct
6 Correct 129 ms 12484 KB Output is correct
7 Correct 927 ms 18148 KB Output is correct
8 Correct 112 ms 13508 KB Output is correct
9 Correct 967 ms 19636 KB Output is correct
10 Correct 571 ms 27344 KB Output is correct
11 Correct 861 ms 42896 KB Output is correct
12 Correct 229 ms 14356 KB Output is correct
13 Correct 263 ms 14784 KB Output is correct
14 Correct 197 ms 15616 KB Output is correct
15 Correct 202 ms 15756 KB Output is correct
16 Correct 1 ms 344 KB Output is correct
17 Correct 3904 ms 44720 KB Output is correct
18 Correct 3286 ms 45640 KB Output is correct
19 Execution timed out 4042 ms 43300 KB Time limit exceeded
20 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 13 ms 604 KB Output is correct
6 Correct 8 ms 604 KB Output is correct
7 Correct 14 ms 604 KB Output is correct
8 Correct 13 ms 600 KB Output is correct
9 Correct 9 ms 860 KB Output is correct
10 Correct 3 ms 348 KB Output is correct
11 Correct 2 ms 348 KB Output is correct
12 Correct 8 ms 604 KB Output is correct
13 Correct 6 ms 604 KB Output is correct
14 Correct 5 ms 600 KB Output is correct
15 Correct 7 ms 604 KB Output is correct
16 Correct 5 ms 604 KB Output is correct
17 Correct 5 ms 344 KB Output is correct
18 Correct 3 ms 348 KB Output is correct
19 Correct 4 ms 348 KB Output is correct
20 Correct 3 ms 348 KB Output is correct
21 Correct 1 ms 544 KB Output is correct
22 Correct 655 ms 42960 KB Output is correct
23 Correct 1363 ms 42668 KB Output is correct
24 Correct 510 ms 42664 KB Output is correct
25 Correct 1181 ms 42480 KB Output is correct
26 Correct 129 ms 12484 KB Output is correct
27 Correct 927 ms 18148 KB Output is correct
28 Correct 112 ms 13508 KB Output is correct
29 Correct 967 ms 19636 KB Output is correct
30 Correct 571 ms 27344 KB Output is correct
31 Correct 861 ms 42896 KB Output is correct
32 Correct 229 ms 14356 KB Output is correct
33 Correct 263 ms 14784 KB Output is correct
34 Correct 197 ms 15616 KB Output is correct
35 Correct 202 ms 15756 KB Output is correct
36 Correct 554 ms 42668 KB Output is correct
37 Correct 1425 ms 43604 KB Output is correct
38 Correct 1251 ms 42772 KB Output is correct
39 Correct 609 ms 44340 KB Output is correct
40 Correct 1126 ms 43180 KB Output is correct
41 Correct 126 ms 13764 KB Output is correct
42 Correct 118 ms 13508 KB Output is correct
43 Correct 973 ms 19380 KB Output is correct
44 Correct 1000 ms 18336 KB Output is correct
45 Correct 660 ms 27496 KB Output is correct
46 Correct 593 ms 26516 KB Output is correct
47 Correct 731 ms 25980 KB Output is correct
48 Correct 269 ms 15660 KB Output is correct
49 Correct 271 ms 15292 KB Output is correct
50 Correct 211 ms 15552 KB Output is correct
51 Correct 206 ms 15812 KB Output is correct
52 Correct 200 ms 15640 KB Output is correct
53 Correct 1 ms 348 KB Output is correct
54 Correct 3457 ms 44204 KB Output is correct
55 Correct 1581 ms 44456 KB Output is correct
56 Correct 3029 ms 43964 KB Output is correct
57 Correct 3226 ms 44080 KB Output is correct
58 Correct 2687 ms 44188 KB Output is correct
59 Correct 1595 ms 43472 KB Output is correct
60 Correct 2671 ms 42572 KB Output is correct
61 Correct 3036 ms 45196 KB Output is correct
62 Correct 2783 ms 42924 KB Output is correct
63 Correct 3043 ms 43768 KB Output is correct
64 Correct 446 ms 15556 KB Output is correct
65 Correct 460 ms 15564 KB Output is correct
66 Correct 434 ms 15300 KB Output is correct
67 Correct 2496 ms 26044 KB Output is correct
68 Correct 2753 ms 27628 KB Output is correct
69 Correct 1769 ms 44548 KB Output is correct
70 Correct 1053 ms 26404 KB Output is correct
71 Correct 1761 ms 42668 KB Output is correct
72 Correct 1410 ms 28588 KB Output is correct
73 Correct 1211 ms 28968 KB Output is correct
74 Correct 732 ms 16572 KB Output is correct
75 Correct 692 ms 16572 KB Output is correct
76 Correct 683 ms 17880 KB Output is correct
77 Correct 638 ms 17604 KB Output is correct
78 Correct 1 ms 344 KB Output is correct
79 Correct 3904 ms 44720 KB Output is correct
80 Correct 3286 ms 45640 KB Output is correct
81 Execution timed out 4042 ms 43300 KB Time limit exceeded
82 Halted 0 ms 0 KB -