#include <bits/stdc++.h>
using namespace std;
#ifdef evenvalue
#include "debug.h"
#define debug(...) print(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...)
#endif
using int64 = long long;
using ld = long double;
template<typename T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using max_heap = priority_queue<T, vector<T>, less<T>>;
namespace read {
int Int() {
int x;
cin >> x;
return x;
}
int64 Int64() {
int64 x;
cin >> x;
return x;
}
char Char() {
char c;
cin >> c;
return c;
}
string String() {
string s;
cin >> s;
return s;
}
double Double() {
return stod(String());
}
ld LongDouble() {
return stold(String());
}
template<typename T1, typename T2>
pair<T1, T2> Pair() {
pair<T1, T2> p;
cin >> p.first >> p.second;
return p;
}
template<typename T>
vector<T> Vec(const int n) {
vector<T> v(n);
for (T &x : v) {
cin >> x;
}
return v;
}
template<typename T>
vector<vector<T>> VecVec(const int n, const int m) {
vector<vector<T>> v(n);
for (vector<T> &vec : v) {
vec = Vec<T>(m);
}
return v;
}
}// namespace read
constexpr int kInf = 1e9 + 10;
constexpr int64 kInf64 = 1e15 + 10;
constexpr int kMod = 1e9 + 7;
constexpr int kMaxN = 2e5 + 10;
struct repeat {
int64 batch = 0;
int64 count = 0;
};
vector<repeat> simulate(const vector<int> &fof, const vector<int> &keys) {
bool ceil = false;
vector<repeat> left;
vector<repeat> right;
for (const int b : keys) {
const int c = fof[b];
left.push_back({b, (c + ceil) / 2});
right.push_back({b, (c + !ceil) / 2});
ceil = ((c & 1) ? !ceil : ceil);
}
while (not right.empty()) {
left.push_back(right.back());
right.pop_back();
}
return left;
}
int64 formula(const int64 b, const int64 x, const int64 l, const int64 r) {
const int64 part1 = l * r * x;
const int64 part2 = b * l * x * x;
const int64 part3 = (r - l + b * x) * b * x * (x - 1) / 2;
const int64 part4 = b * b * x * (x - 1) * (2 * x - 1) / 6;
return part1 + part2 + part3 - part4;
}
int64 diversities(const vector<int> &fof, const vector<int> &keys) {
vector<repeat> repeats = simulate(fof, keys);
const int kReps = repeats.size();
vector<int64> pref(kReps);
vector<int64> suff(kReps);
for (int i = 1; i < kReps; i++) {
pref[i] = pref[i - 1] + (repeats[i - 1].batch * repeats[i - 1].count);
}
for (int i = kReps - 2; i >= 0; i--) {
suff[i] = suff[i + 1] + (repeats[i + 1].batch * repeats[i + 1].count);
}
const int64 n = suff[0] + repeats[0].batch * repeats[0].count;
int64 ans = n * (n + 1) / 2;
for (int i = 0; i < kReps; i++) {
ans += formula(repeats[i].batch, repeats[i].count, pref[i], suff[i]);
}
return ans;
}
inline int64 hilbertOrder(int x, int y, int pow, int rotate) {
if (pow == 0) {
return 0;
}
int hpow = 1 << (pow - 1);
int seg = (x < hpow) ? ((y < hpow) ? 0 : 3)
: ((y < hpow) ? 1 : 2);
seg = (seg + rotate) & 3;
const int rotateDelta[4] = {3, 0, 0, 1};
int nx = x & (x ^ hpow), ny = y & (y ^ hpow);
int nrot = (rotate + rotateDelta[seg]) & 3;
int64 subSquareSize = int64(1) << (2 * pow - 2);
int64 ans = seg * subSquareSize;
int64 add = hilbertOrder(nx, ny, pow - 1, nrot);
ans += (seg == 1 || seg == 2) ? add : (subSquareSize - add - 1);
return ans;
}
class mo_s {
struct query {
int l, r, v, t;
int64 hilbert;
int64 ans;
query(const int l, const int r, const int v, const int t, const int64 h) : l(l), r(r), v(v), t(t), hilbert(h), ans(0) {}
};
const int kBlockSize = 550;
const int n;
const vector<int> a;
vector<query> queries;
[[nodiscard]] int block_of(const int i) const {
return i / kBlockSize;
}
public:
explicit mo_s(const vector<int> &a) : n(a.size()), a(a) {}
void add_query(const int l, const int r, const int v, const int t) {
const int64 order = hilbertOrder(l, r, 20, 0);
queries.emplace_back(l, r, v, t, order);
}
vector<int64> solve() {
sort(queries.begin(), queries.end(), [&](const query &q1, const query &q2) {
return q1.hilbert < q2.hilbert;
});
const int kDistinct = *max_element(a.begin(), a.end()) + 1;
const int kMaxFreq = 3e5;
vector<int> freq(kDistinct);
vector<int> fof(kMaxFreq + 1);//frequency of frequencies
vector<int> options;
fof[0] = kDistinct;
auto add = [&](const int i) {
const int f = freq[a[i]]++;
fof[f]--;
fof[f + 1]++;
options.push_back(f + 1);
};
auto rem = [&](const int i) {
const int f = freq[a[i]]--;
fof[f]--;
fof[f - 1]++;
options.push_back(f - 1);
};
for (int i = 0, l = 0, r = -1; i < queries.size(); i++) {
while (l > queries[i].l) add(--l);
while (r < queries[i].r) add(++r);
while (l < queries[i].l) rem(l++);
while (r > queries[i].r) rem(r--);
options.erase(remove_if(options.begin(), options.end(), [&](const int x) {
return fof[x] == 0;
}),
options.end());
sort(options.begin(), options.end());
options.erase(unique(options.begin(), options.end()), options.end());
queries[i].ans = diversities(fof, options);
}
sort(queries.begin(), queries.end(), [](const query &q1, const query &q2) {
return q1.t < q2.t;
});
vector<int64> ans(queries.size());
for (int i = 0; const query &q : queries) {
ans[i++] = q.ans;
}
return ans;
}
};
template<typename T>
class CoordinateCompression {
bool sorted = false;
vector<T> v;
public:
void add(const T &x) {
v.push_back(x);
}
void compress() {
sort(v.begin(), v.end());
v.erase(unique(v.begin(), v.end()), v.end());
sorted = true;
}
int get(const int x) {
if (not sorted) assert(false);
return distance(v.begin(), lower_bound(v.begin(), v.end(), x));
}
int size() {
return v.size();
}
};
vector<int> compress(vector<int> a) {
CoordinateCompression<int> cc;
for (const int x : a) {
cc.add(x);
}
cc.compress();
for (int &x : a) {
x = cc.get(x);
}
return a;
}
inline void solution() {
const int n = read::Int();
const int q = read::Int();
const vector<int> a = compress(read::Vec<int>(n));
mo_s mo(a);
for (int i = 0; i < q; i++) {
const int l = read::Int() - 1;
const int r = read::Int() - 1;
mo.add_query(l, r, 0, i);
}
vector<int64> ans = mo.solve();
for (const int64 x : ans) {
cout << x << '\n';
}
}
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
//freopen(".in", "r", stdin);
//freopen(".out", "w", stdout);
cout << fixed << setprecision(10);
int testcases = 1;
//cin >> testcases;
while (testcases--) {
solution();
}
}
Compilation message
diversity.cpp: In member function 'std::vector<long long int> mo_s::solve()':
diversity.cpp:203:38: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<mo_s::query>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
203 | for (int i = 0, l = 0, r = -1; i < queries.size(); i++) {
| ~~^~~~~~~~~~~~~~~~
diversity.cpp:224:21: warning: range-based 'for' loops with initializer only available with '-std=c++2a' or '-std=gnu++2a'
224 | for (int i = 0; const query &q : queries) {
| ^~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1628 KB |
Output is correct |
2 |
Correct |
1 ms |
1628 KB |
Output is correct |
3 |
Correct |
1 ms |
1628 KB |
Output is correct |
4 |
Correct |
1 ms |
1880 KB |
Output is correct |
5 |
Correct |
1 ms |
1628 KB |
Output is correct |
6 |
Correct |
1 ms |
1628 KB |
Output is correct |
7 |
Correct |
1 ms |
1628 KB |
Output is correct |
8 |
Correct |
1 ms |
1628 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
1 ms |
1628 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1628 KB |
Output is correct |
2 |
Correct |
1 ms |
1480 KB |
Output is correct |
3 |
Correct |
2 ms |
1628 KB |
Output is correct |
4 |
Correct |
9 ms |
3412 KB |
Output is correct |
5 |
Correct |
17 ms |
5316 KB |
Output is correct |
6 |
Correct |
28 ms |
7668 KB |
Output is correct |
7 |
Correct |
30 ms |
7988 KB |
Output is correct |
8 |
Correct |
27 ms |
7768 KB |
Output is correct |
9 |
Correct |
27 ms |
7744 KB |
Output is correct |
10 |
Correct |
27 ms |
7736 KB |
Output is correct |
11 |
Correct |
27 ms |
7744 KB |
Output is correct |
12 |
Correct |
29 ms |
7736 KB |
Output is correct |
13 |
Correct |
28 ms |
7736 KB |
Output is correct |
14 |
Correct |
27 ms |
8760 KB |
Output is correct |
15 |
Correct |
28 ms |
7736 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1628 KB |
Output is correct |
2 |
Correct |
1 ms |
1480 KB |
Output is correct |
3 |
Correct |
2 ms |
1628 KB |
Output is correct |
4 |
Correct |
9 ms |
3412 KB |
Output is correct |
5 |
Correct |
17 ms |
5316 KB |
Output is correct |
6 |
Correct |
28 ms |
7668 KB |
Output is correct |
7 |
Correct |
30 ms |
7988 KB |
Output is correct |
8 |
Correct |
27 ms |
7768 KB |
Output is correct |
9 |
Correct |
27 ms |
7744 KB |
Output is correct |
10 |
Correct |
27 ms |
7736 KB |
Output is correct |
11 |
Correct |
27 ms |
7744 KB |
Output is correct |
12 |
Correct |
29 ms |
7736 KB |
Output is correct |
13 |
Correct |
28 ms |
7736 KB |
Output is correct |
14 |
Correct |
27 ms |
8760 KB |
Output is correct |
15 |
Correct |
28 ms |
7736 KB |
Output is correct |
16 |
Correct |
1 ms |
1884 KB |
Output is correct |
17 |
Correct |
1 ms |
1628 KB |
Output is correct |
18 |
Correct |
2 ms |
1800 KB |
Output is correct |
19 |
Correct |
10 ms |
3572 KB |
Output is correct |
20 |
Correct |
21 ms |
5316 KB |
Output is correct |
21 |
Correct |
30 ms |
7860 KB |
Output is correct |
22 |
Correct |
37 ms |
7736 KB |
Output is correct |
23 |
Correct |
30 ms |
8252 KB |
Output is correct |
24 |
Correct |
32 ms |
7932 KB |
Output is correct |
25 |
Correct |
34 ms |
8948 KB |
Output is correct |
26 |
Correct |
31 ms |
7736 KB |
Output is correct |
27 |
Correct |
31 ms |
7732 KB |
Output is correct |
28 |
Correct |
34 ms |
7876 KB |
Output is correct |
29 |
Correct |
31 ms |
7864 KB |
Output is correct |
30 |
Correct |
34 ms |
7992 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1628 KB |
Output is correct |
2 |
Correct |
1 ms |
1480 KB |
Output is correct |
3 |
Correct |
2 ms |
1628 KB |
Output is correct |
4 |
Correct |
9 ms |
3412 KB |
Output is correct |
5 |
Correct |
17 ms |
5316 KB |
Output is correct |
6 |
Correct |
28 ms |
7668 KB |
Output is correct |
7 |
Correct |
30 ms |
7988 KB |
Output is correct |
8 |
Correct |
27 ms |
7768 KB |
Output is correct |
9 |
Correct |
27 ms |
7744 KB |
Output is correct |
10 |
Correct |
27 ms |
7736 KB |
Output is correct |
11 |
Correct |
27 ms |
7744 KB |
Output is correct |
12 |
Correct |
29 ms |
7736 KB |
Output is correct |
13 |
Correct |
28 ms |
7736 KB |
Output is correct |
14 |
Correct |
27 ms |
8760 KB |
Output is correct |
15 |
Correct |
28 ms |
7736 KB |
Output is correct |
16 |
Correct |
1 ms |
1884 KB |
Output is correct |
17 |
Correct |
1 ms |
1628 KB |
Output is correct |
18 |
Correct |
2 ms |
1800 KB |
Output is correct |
19 |
Correct |
10 ms |
3572 KB |
Output is correct |
20 |
Correct |
21 ms |
5316 KB |
Output is correct |
21 |
Correct |
30 ms |
7860 KB |
Output is correct |
22 |
Correct |
37 ms |
7736 KB |
Output is correct |
23 |
Correct |
30 ms |
8252 KB |
Output is correct |
24 |
Correct |
32 ms |
7932 KB |
Output is correct |
25 |
Correct |
34 ms |
8948 KB |
Output is correct |
26 |
Correct |
31 ms |
7736 KB |
Output is correct |
27 |
Correct |
31 ms |
7732 KB |
Output is correct |
28 |
Correct |
34 ms |
7876 KB |
Output is correct |
29 |
Correct |
31 ms |
7864 KB |
Output is correct |
30 |
Correct |
34 ms |
7992 KB |
Output is correct |
31 |
Correct |
1 ms |
1628 KB |
Output is correct |
32 |
Correct |
1 ms |
1880 KB |
Output is correct |
33 |
Correct |
1 ms |
1628 KB |
Output is correct |
34 |
Correct |
2 ms |
1628 KB |
Output is correct |
35 |
Correct |
3 ms |
1628 KB |
Output is correct |
36 |
Correct |
3 ms |
1628 KB |
Output is correct |
37 |
Correct |
9 ms |
2516 KB |
Output is correct |
38 |
Correct |
10 ms |
2588 KB |
Output is correct |
39 |
Correct |
20 ms |
3664 KB |
Output is correct |
40 |
Correct |
39 ms |
5568 KB |
Output is correct |
41 |
Correct |
65 ms |
9124 KB |
Output is correct |
42 |
Correct |
57 ms |
8124 KB |
Output is correct |
43 |
Correct |
56 ms |
8276 KB |
Output is correct |
44 |
Correct |
57 ms |
8304 KB |
Output is correct |
45 |
Correct |
57 ms |
8248 KB |
Output is correct |
46 |
Correct |
60 ms |
8248 KB |
Output is correct |
47 |
Correct |
57 ms |
8248 KB |
Output is correct |
48 |
Correct |
61 ms |
8248 KB |
Output is correct |
49 |
Correct |
58 ms |
8300 KB |
Output is correct |
50 |
Correct |
61 ms |
8236 KB |
Output is correct |
51 |
Correct |
56 ms |
8120 KB |
Output is correct |
52 |
Correct |
56 ms |
8276 KB |
Output is correct |
53 |
Correct |
56 ms |
8280 KB |
Output is correct |
54 |
Correct |
56 ms |
8432 KB |
Output is correct |
55 |
Correct |
57 ms |
8208 KB |
Output is correct |
56 |
Correct |
57 ms |
8248 KB |
Output is correct |
57 |
Correct |
56 ms |
8248 KB |
Output is correct |
58 |
Correct |
59 ms |
8248 KB |
Output is correct |
59 |
Correct |
57 ms |
8284 KB |
Output is correct |
60 |
Correct |
57 ms |
8248 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1628 KB |
Output is correct |
2 |
Correct |
1 ms |
1628 KB |
Output is correct |
3 |
Correct |
1 ms |
1628 KB |
Output is correct |
4 |
Correct |
1 ms |
1880 KB |
Output is correct |
5 |
Correct |
1 ms |
1628 KB |
Output is correct |
6 |
Correct |
1 ms |
1628 KB |
Output is correct |
7 |
Correct |
1 ms |
1628 KB |
Output is correct |
8 |
Correct |
1 ms |
1628 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
1 ms |
1628 KB |
Output is correct |
11 |
Correct |
1 ms |
1628 KB |
Output is correct |
12 |
Correct |
1 ms |
1480 KB |
Output is correct |
13 |
Correct |
2 ms |
1628 KB |
Output is correct |
14 |
Correct |
9 ms |
3412 KB |
Output is correct |
15 |
Correct |
17 ms |
5316 KB |
Output is correct |
16 |
Correct |
28 ms |
7668 KB |
Output is correct |
17 |
Correct |
30 ms |
7988 KB |
Output is correct |
18 |
Correct |
27 ms |
7768 KB |
Output is correct |
19 |
Correct |
27 ms |
7744 KB |
Output is correct |
20 |
Correct |
27 ms |
7736 KB |
Output is correct |
21 |
Correct |
27 ms |
7744 KB |
Output is correct |
22 |
Correct |
29 ms |
7736 KB |
Output is correct |
23 |
Correct |
28 ms |
7736 KB |
Output is correct |
24 |
Correct |
27 ms |
8760 KB |
Output is correct |
25 |
Correct |
28 ms |
7736 KB |
Output is correct |
26 |
Correct |
1 ms |
1884 KB |
Output is correct |
27 |
Correct |
1 ms |
1628 KB |
Output is correct |
28 |
Correct |
2 ms |
1800 KB |
Output is correct |
29 |
Correct |
10 ms |
3572 KB |
Output is correct |
30 |
Correct |
21 ms |
5316 KB |
Output is correct |
31 |
Correct |
30 ms |
7860 KB |
Output is correct |
32 |
Correct |
37 ms |
7736 KB |
Output is correct |
33 |
Correct |
30 ms |
8252 KB |
Output is correct |
34 |
Correct |
32 ms |
7932 KB |
Output is correct |
35 |
Correct |
34 ms |
8948 KB |
Output is correct |
36 |
Correct |
31 ms |
7736 KB |
Output is correct |
37 |
Correct |
31 ms |
7732 KB |
Output is correct |
38 |
Correct |
34 ms |
7876 KB |
Output is correct |
39 |
Correct |
31 ms |
7864 KB |
Output is correct |
40 |
Correct |
34 ms |
7992 KB |
Output is correct |
41 |
Correct |
1 ms |
1628 KB |
Output is correct |
42 |
Correct |
1 ms |
1880 KB |
Output is correct |
43 |
Correct |
1 ms |
1628 KB |
Output is correct |
44 |
Correct |
2 ms |
1628 KB |
Output is correct |
45 |
Correct |
3 ms |
1628 KB |
Output is correct |
46 |
Correct |
3 ms |
1628 KB |
Output is correct |
47 |
Correct |
9 ms |
2516 KB |
Output is correct |
48 |
Correct |
10 ms |
2588 KB |
Output is correct |
49 |
Correct |
20 ms |
3664 KB |
Output is correct |
50 |
Correct |
39 ms |
5568 KB |
Output is correct |
51 |
Correct |
65 ms |
9124 KB |
Output is correct |
52 |
Correct |
57 ms |
8124 KB |
Output is correct |
53 |
Correct |
56 ms |
8276 KB |
Output is correct |
54 |
Correct |
57 ms |
8304 KB |
Output is correct |
55 |
Correct |
57 ms |
8248 KB |
Output is correct |
56 |
Correct |
60 ms |
8248 KB |
Output is correct |
57 |
Correct |
57 ms |
8248 KB |
Output is correct |
58 |
Correct |
61 ms |
8248 KB |
Output is correct |
59 |
Correct |
58 ms |
8300 KB |
Output is correct |
60 |
Correct |
61 ms |
8236 KB |
Output is correct |
61 |
Correct |
56 ms |
8120 KB |
Output is correct |
62 |
Correct |
56 ms |
8276 KB |
Output is correct |
63 |
Correct |
56 ms |
8280 KB |
Output is correct |
64 |
Correct |
56 ms |
8432 KB |
Output is correct |
65 |
Correct |
57 ms |
8208 KB |
Output is correct |
66 |
Correct |
57 ms |
8248 KB |
Output is correct |
67 |
Correct |
56 ms |
8248 KB |
Output is correct |
68 |
Correct |
59 ms |
8248 KB |
Output is correct |
69 |
Correct |
57 ms |
8284 KB |
Output is correct |
70 |
Correct |
57 ms |
8248 KB |
Output is correct |
71 |
Correct |
12 ms |
2588 KB |
Output is correct |
72 |
Correct |
11 ms |
2588 KB |
Output is correct |
73 |
Correct |
11 ms |
2588 KB |
Output is correct |
74 |
Correct |
11 ms |
2588 KB |
Output is correct |
75 |
Correct |
11 ms |
2588 KB |
Output is correct |
76 |
Correct |
22 ms |
3764 KB |
Output is correct |
77 |
Correct |
24 ms |
3660 KB |
Output is correct |
78 |
Correct |
22 ms |
3660 KB |
Output is correct |
79 |
Correct |
22 ms |
3668 KB |
Output is correct |
80 |
Correct |
22 ms |
3756 KB |
Output is correct |
81 |
Correct |
45 ms |
5812 KB |
Output is correct |
82 |
Correct |
45 ms |
5832 KB |
Output is correct |
83 |
Correct |
50 ms |
5936 KB |
Output is correct |
84 |
Correct |
45 ms |
5908 KB |
Output is correct |
85 |
Correct |
47 ms |
5824 KB |
Output is correct |
86 |
Correct |
50 ms |
5928 KB |
Output is correct |
87 |
Correct |
55 ms |
6212 KB |
Output is correct |
88 |
Correct |
49 ms |
5884 KB |
Output is correct |
89 |
Correct |
48 ms |
6036 KB |
Output is correct |
90 |
Correct |
52 ms |
6016 KB |
Output is correct |
91 |
Correct |
78 ms |
9188 KB |
Output is correct |
92 |
Correct |
83 ms |
10316 KB |
Output is correct |
93 |
Correct |
82 ms |
9128 KB |
Output is correct |
94 |
Correct |
78 ms |
10028 KB |
Output is correct |
95 |
Correct |
78 ms |
9272 KB |
Output is correct |
96 |
Correct |
83 ms |
10824 KB |
Output is correct |
97 |
Correct |
90 ms |
9800 KB |
Output is correct |
98 |
Correct |
83 ms |
9776 KB |
Output is correct |
99 |
Correct |
84 ms |
9780 KB |
Output is correct |
100 |
Correct |
87 ms |
10324 KB |
Output is correct |
101 |
Correct |
91 ms |
9784 KB |
Output is correct |
102 |
Correct |
85 ms |
9804 KB |
Output is correct |
103 |
Correct |
84 ms |
9784 KB |
Output is correct |
104 |
Correct |
88 ms |
10064 KB |
Output is correct |
105 |
Correct |
84 ms |
9804 KB |
Output is correct |
106 |
Correct |
84 ms |
10036 KB |
Output is correct |
107 |
Correct |
85 ms |
9916 KB |
Output is correct |
108 |
Correct |
84 ms |
10040 KB |
Output is correct |
109 |
Correct |
89 ms |
10116 KB |
Output is correct |
110 |
Correct |
84 ms |
10104 KB |
Output is correct |
111 |
Correct |
84 ms |
10036 KB |
Output is correct |
112 |
Correct |
84 ms |
10096 KB |
Output is correct |
113 |
Correct |
89 ms |
10100 KB |
Output is correct |
114 |
Correct |
84 ms |
9916 KB |
Output is correct |
115 |
Correct |
84 ms |
10036 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1628 KB |
Output is correct |
2 |
Correct |
1 ms |
1628 KB |
Output is correct |
3 |
Correct |
1 ms |
1628 KB |
Output is correct |
4 |
Correct |
1 ms |
1880 KB |
Output is correct |
5 |
Correct |
1 ms |
1628 KB |
Output is correct |
6 |
Correct |
1 ms |
1628 KB |
Output is correct |
7 |
Correct |
1 ms |
1628 KB |
Output is correct |
8 |
Correct |
1 ms |
1628 KB |
Output is correct |
9 |
Correct |
1 ms |
1628 KB |
Output is correct |
10 |
Correct |
1 ms |
1628 KB |
Output is correct |
11 |
Correct |
1 ms |
1628 KB |
Output is correct |
12 |
Correct |
1 ms |
1480 KB |
Output is correct |
13 |
Correct |
2 ms |
1628 KB |
Output is correct |
14 |
Correct |
9 ms |
3412 KB |
Output is correct |
15 |
Correct |
17 ms |
5316 KB |
Output is correct |
16 |
Correct |
28 ms |
7668 KB |
Output is correct |
17 |
Correct |
30 ms |
7988 KB |
Output is correct |
18 |
Correct |
27 ms |
7768 KB |
Output is correct |
19 |
Correct |
27 ms |
7744 KB |
Output is correct |
20 |
Correct |
27 ms |
7736 KB |
Output is correct |
21 |
Correct |
27 ms |
7744 KB |
Output is correct |
22 |
Correct |
29 ms |
7736 KB |
Output is correct |
23 |
Correct |
28 ms |
7736 KB |
Output is correct |
24 |
Correct |
27 ms |
8760 KB |
Output is correct |
25 |
Correct |
28 ms |
7736 KB |
Output is correct |
26 |
Correct |
1 ms |
1884 KB |
Output is correct |
27 |
Correct |
1 ms |
1628 KB |
Output is correct |
28 |
Correct |
2 ms |
1800 KB |
Output is correct |
29 |
Correct |
10 ms |
3572 KB |
Output is correct |
30 |
Correct |
21 ms |
5316 KB |
Output is correct |
31 |
Correct |
30 ms |
7860 KB |
Output is correct |
32 |
Correct |
37 ms |
7736 KB |
Output is correct |
33 |
Correct |
30 ms |
8252 KB |
Output is correct |
34 |
Correct |
32 ms |
7932 KB |
Output is correct |
35 |
Correct |
34 ms |
8948 KB |
Output is correct |
36 |
Correct |
31 ms |
7736 KB |
Output is correct |
37 |
Correct |
31 ms |
7732 KB |
Output is correct |
38 |
Correct |
34 ms |
7876 KB |
Output is correct |
39 |
Correct |
31 ms |
7864 KB |
Output is correct |
40 |
Correct |
34 ms |
7992 KB |
Output is correct |
41 |
Correct |
1 ms |
1628 KB |
Output is correct |
42 |
Correct |
1 ms |
1880 KB |
Output is correct |
43 |
Correct |
1 ms |
1628 KB |
Output is correct |
44 |
Correct |
2 ms |
1628 KB |
Output is correct |
45 |
Correct |
3 ms |
1628 KB |
Output is correct |
46 |
Correct |
3 ms |
1628 KB |
Output is correct |
47 |
Correct |
9 ms |
2516 KB |
Output is correct |
48 |
Correct |
10 ms |
2588 KB |
Output is correct |
49 |
Correct |
20 ms |
3664 KB |
Output is correct |
50 |
Correct |
39 ms |
5568 KB |
Output is correct |
51 |
Correct |
65 ms |
9124 KB |
Output is correct |
52 |
Correct |
57 ms |
8124 KB |
Output is correct |
53 |
Correct |
56 ms |
8276 KB |
Output is correct |
54 |
Correct |
57 ms |
8304 KB |
Output is correct |
55 |
Correct |
57 ms |
8248 KB |
Output is correct |
56 |
Correct |
60 ms |
8248 KB |
Output is correct |
57 |
Correct |
57 ms |
8248 KB |
Output is correct |
58 |
Correct |
61 ms |
8248 KB |
Output is correct |
59 |
Correct |
58 ms |
8300 KB |
Output is correct |
60 |
Correct |
61 ms |
8236 KB |
Output is correct |
61 |
Correct |
56 ms |
8120 KB |
Output is correct |
62 |
Correct |
56 ms |
8276 KB |
Output is correct |
63 |
Correct |
56 ms |
8280 KB |
Output is correct |
64 |
Correct |
56 ms |
8432 KB |
Output is correct |
65 |
Correct |
57 ms |
8208 KB |
Output is correct |
66 |
Correct |
57 ms |
8248 KB |
Output is correct |
67 |
Correct |
56 ms |
8248 KB |
Output is correct |
68 |
Correct |
59 ms |
8248 KB |
Output is correct |
69 |
Correct |
57 ms |
8284 KB |
Output is correct |
70 |
Correct |
57 ms |
8248 KB |
Output is correct |
71 |
Correct |
12 ms |
2588 KB |
Output is correct |
72 |
Correct |
11 ms |
2588 KB |
Output is correct |
73 |
Correct |
11 ms |
2588 KB |
Output is correct |
74 |
Correct |
11 ms |
2588 KB |
Output is correct |
75 |
Correct |
11 ms |
2588 KB |
Output is correct |
76 |
Correct |
22 ms |
3764 KB |
Output is correct |
77 |
Correct |
24 ms |
3660 KB |
Output is correct |
78 |
Correct |
22 ms |
3660 KB |
Output is correct |
79 |
Correct |
22 ms |
3668 KB |
Output is correct |
80 |
Correct |
22 ms |
3756 KB |
Output is correct |
81 |
Correct |
45 ms |
5812 KB |
Output is correct |
82 |
Correct |
45 ms |
5832 KB |
Output is correct |
83 |
Correct |
50 ms |
5936 KB |
Output is correct |
84 |
Correct |
45 ms |
5908 KB |
Output is correct |
85 |
Correct |
47 ms |
5824 KB |
Output is correct |
86 |
Correct |
50 ms |
5928 KB |
Output is correct |
87 |
Correct |
55 ms |
6212 KB |
Output is correct |
88 |
Correct |
49 ms |
5884 KB |
Output is correct |
89 |
Correct |
48 ms |
6036 KB |
Output is correct |
90 |
Correct |
52 ms |
6016 KB |
Output is correct |
91 |
Correct |
78 ms |
9188 KB |
Output is correct |
92 |
Correct |
83 ms |
10316 KB |
Output is correct |
93 |
Correct |
82 ms |
9128 KB |
Output is correct |
94 |
Correct |
78 ms |
10028 KB |
Output is correct |
95 |
Correct |
78 ms |
9272 KB |
Output is correct |
96 |
Correct |
83 ms |
10824 KB |
Output is correct |
97 |
Correct |
90 ms |
9800 KB |
Output is correct |
98 |
Correct |
83 ms |
9776 KB |
Output is correct |
99 |
Correct |
84 ms |
9780 KB |
Output is correct |
100 |
Correct |
87 ms |
10324 KB |
Output is correct |
101 |
Correct |
91 ms |
9784 KB |
Output is correct |
102 |
Correct |
85 ms |
9804 KB |
Output is correct |
103 |
Correct |
84 ms |
9784 KB |
Output is correct |
104 |
Correct |
88 ms |
10064 KB |
Output is correct |
105 |
Correct |
84 ms |
9804 KB |
Output is correct |
106 |
Correct |
84 ms |
10036 KB |
Output is correct |
107 |
Correct |
85 ms |
9916 KB |
Output is correct |
108 |
Correct |
84 ms |
10040 KB |
Output is correct |
109 |
Correct |
89 ms |
10116 KB |
Output is correct |
110 |
Correct |
84 ms |
10104 KB |
Output is correct |
111 |
Correct |
84 ms |
10036 KB |
Output is correct |
112 |
Correct |
84 ms |
10096 KB |
Output is correct |
113 |
Correct |
89 ms |
10100 KB |
Output is correct |
114 |
Correct |
84 ms |
9916 KB |
Output is correct |
115 |
Correct |
84 ms |
10036 KB |
Output is correct |
116 |
Correct |
180 ms |
4164 KB |
Output is correct |
117 |
Correct |
239 ms |
4296 KB |
Output is correct |
118 |
Correct |
443 ms |
4744 KB |
Output is correct |
119 |
Correct |
687 ms |
4784 KB |
Output is correct |
120 |
Correct |
596 ms |
4744 KB |
Output is correct |
121 |
Correct |
1162 ms |
5316 KB |
Output is correct |
122 |
Correct |
981 ms |
5576 KB |
Output is correct |
123 |
Correct |
2110 ms |
7228 KB |
Output is correct |
124 |
Correct |
1624 ms |
7232 KB |
Output is correct |
125 |
Correct |
1401 ms |
7264 KB |
Output is correct |
126 |
Correct |
1854 ms |
9148 KB |
Output is correct |
127 |
Correct |
1895 ms |
9168 KB |
Output is correct |
128 |
Correct |
1902 ms |
9148 KB |
Output is correct |
129 |
Correct |
1903 ms |
9144 KB |
Output is correct |
130 |
Correct |
1937 ms |
9008 KB |
Output is correct |
131 |
Correct |
2557 ms |
9192 KB |
Output is correct |
132 |
Correct |
2613 ms |
9724 KB |
Output is correct |
133 |
Correct |
2456 ms |
9196 KB |
Output is correct |
134 |
Correct |
2530 ms |
9180 KB |
Output is correct |
135 |
Correct |
2548 ms |
9216 KB |
Output is correct |
136 |
Correct |
2580 ms |
9180 KB |
Output is correct |
137 |
Correct |
2523 ms |
9224 KB |
Output is correct |
138 |
Correct |
2578 ms |
9228 KB |
Output is correct |
139 |
Correct |
2523 ms |
9196 KB |
Output is correct |
140 |
Correct |
2562 ms |
9200 KB |
Output is correct |
141 |
Correct |
3009 ms |
9236 KB |
Output is correct |
142 |
Correct |
3010 ms |
9228 KB |
Output is correct |
143 |
Correct |
3006 ms |
9236 KB |
Output is correct |
144 |
Correct |
3035 ms |
9228 KB |
Output is correct |
145 |
Correct |
3023 ms |
9236 KB |
Output is correct |
146 |
Correct |
2512 ms |
9492 KB |
Output is correct |
147 |
Correct |
2538 ms |
9480 KB |
Output is correct |
148 |
Correct |
2557 ms |
9492 KB |
Output is correct |
149 |
Correct |
2537 ms |
9496 KB |
Output is correct |
150 |
Correct |
2559 ms |
9504 KB |
Output is correct |
151 |
Correct |
2174 ms |
10064 KB |
Output is correct |
152 |
Correct |
2214 ms |
10072 KB |
Output is correct |
153 |
Correct |
2193 ms |
9772 KB |
Output is correct |
154 |
Correct |
2193 ms |
9516 KB |
Output is correct |
155 |
Correct |
2206 ms |
9532 KB |
Output is correct |
156 |
Correct |
2181 ms |
9812 KB |
Output is correct |
157 |
Correct |
2219 ms |
10064 KB |
Output is correct |
158 |
Correct |
2271 ms |
9792 KB |
Output is correct |
159 |
Correct |
2185 ms |
9804 KB |
Output is correct |
160 |
Correct |
2194 ms |
10020 KB |
Output is correct |
161 |
Correct |
1369 ms |
10012 KB |
Output is correct |
162 |
Correct |
1393 ms |
9908 KB |
Output is correct |
163 |
Correct |
1354 ms |
9912 KB |
Output is correct |
164 |
Correct |
1383 ms |
9904 KB |
Output is correct |
165 |
Correct |
1372 ms |
9892 KB |
Output is correct |
166 |
Correct |
2225 ms |
9696 KB |
Output is correct |
167 |
Correct |
2272 ms |
9684 KB |
Output is correct |
168 |
Correct |
2263 ms |
9692 KB |
Output is correct |
169 |
Correct |
2200 ms |
9696 KB |
Output is correct |
170 |
Correct |
2207 ms |
9692 KB |
Output is correct |
171 |
Correct |
1762 ms |
9776 KB |
Output is correct |
172 |
Correct |
1777 ms |
9772 KB |
Output is correct |
173 |
Correct |
1755 ms |
9768 KB |
Output is correct |
174 |
Correct |
1749 ms |
9756 KB |
Output is correct |
175 |
Correct |
1782 ms |
9772 KB |
Output is correct |