# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
344420 |
2021-01-05T18:47:04 Z |
Nursik |
Pilot (NOI19_pilot) |
C++14 |
|
54 ms |
7300 KB |
#include <bits/stdc++.h>
#define f first
#define s second
#define ll long long
#define pb push_back
#define all(v) v.begin(),v.end()
#define ld long double
using namespace std;
void data() {
#ifdef NURS
freopen("main.in", "r", stdin);
freopen("main.out", "w", stdout);
#endif
}
void win()
{
ios_base::sync_with_stdio(0),
cin.tie(0),cout.tie(0);
}
const ld eps = 1e-6;
const int N = 1e6 + 500;
const int mod = 1e9 + 7;
const ll hh = 100010683;
const ll hh2 = 150005819;
int n, q;
int a[N], pref[N], pref2[N];
void rec(int l = 1, int r = n)
{
if (l == r)
{
pref2[a[l]]++;
return;
}
int mid = (l + r) / 2;
rec(l, mid);
rec(mid + 1, r);
for (int i = mid; i >= l; i--)
{
pref[i] = max(pref[i + 1], a[i]);
}
int cur = 0, uk = mid + 1;
for (int i = mid + 1; i <= r; i++)
{
cur = max(cur, a[i]);
while (cur >= pref[uk - 1] && uk - 1 >= l)
{
uk--;
}
pref2[cur] += max(mid - uk + 1, 0);
}
for (int i = mid; i >= l; i--)
{
pref[i] = 0;
}
cur = 0;
for (int i = mid + 1; i <= r; i++)
{
pref[i] = max(pref[i - 1], a[i]);
}
uk = mid;
for (int i = mid; i >= l; i--)
{
cur = max(cur, a[i]);
while (cur > pref[uk + 1] && uk + 1 <= r)
{
uk++;
}
pref2[cur] += max(uk - mid , 0);
}
for (int i = mid + 1; i <= r; i++)
{
pref[i] = 0;
}
}
int main()
{
data();
win();
cin >> n >> q;
for (int i = 1; i <= n; i++)
{
cin >> a[i];
}
rec();
pref2[0] = 0;
for (int i = 1; i <= 1e6; i++)
{
pref2[i] += pref2[i - 1];
}
for (int i = 1; i <= q; i++)
{
int x;
cin >> x;
cout << pref2[x] << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4204 KB |
Output is correct |
2 |
Correct |
4 ms |
4204 KB |
Output is correct |
3 |
Correct |
4 ms |
4204 KB |
Output is correct |
4 |
Correct |
4 ms |
4204 KB |
Output is correct |
5 |
Correct |
4 ms |
4204 KB |
Output is correct |
6 |
Correct |
4 ms |
4204 KB |
Output is correct |
7 |
Correct |
4 ms |
4204 KB |
Output is correct |
8 |
Correct |
4 ms |
4204 KB |
Output is correct |
9 |
Correct |
4 ms |
4224 KB |
Output is correct |
10 |
Correct |
4 ms |
4204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4204 KB |
Output is correct |
2 |
Correct |
4 ms |
4204 KB |
Output is correct |
3 |
Correct |
4 ms |
4204 KB |
Output is correct |
4 |
Correct |
4 ms |
4204 KB |
Output is correct |
5 |
Correct |
4 ms |
4204 KB |
Output is correct |
6 |
Correct |
4 ms |
4204 KB |
Output is correct |
7 |
Correct |
4 ms |
4204 KB |
Output is correct |
8 |
Correct |
4 ms |
4204 KB |
Output is correct |
9 |
Correct |
4 ms |
4224 KB |
Output is correct |
10 |
Correct |
4 ms |
4204 KB |
Output is correct |
11 |
Correct |
4 ms |
4204 KB |
Output is correct |
12 |
Correct |
4 ms |
4204 KB |
Output is correct |
13 |
Correct |
4 ms |
4204 KB |
Output is correct |
14 |
Correct |
4 ms |
4224 KB |
Output is correct |
15 |
Correct |
4 ms |
4352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4204 KB |
Output is correct |
2 |
Correct |
4 ms |
4204 KB |
Output is correct |
3 |
Correct |
4 ms |
4204 KB |
Output is correct |
4 |
Correct |
4 ms |
4204 KB |
Output is correct |
5 |
Correct |
4 ms |
4204 KB |
Output is correct |
6 |
Correct |
4 ms |
4204 KB |
Output is correct |
7 |
Correct |
4 ms |
4204 KB |
Output is correct |
8 |
Correct |
4 ms |
4204 KB |
Output is correct |
9 |
Correct |
4 ms |
4224 KB |
Output is correct |
10 |
Correct |
4 ms |
4204 KB |
Output is correct |
11 |
Correct |
4 ms |
4204 KB |
Output is correct |
12 |
Correct |
4 ms |
4204 KB |
Output is correct |
13 |
Correct |
4 ms |
4204 KB |
Output is correct |
14 |
Correct |
4 ms |
4224 KB |
Output is correct |
15 |
Correct |
4 ms |
4352 KB |
Output is correct |
16 |
Correct |
4 ms |
4204 KB |
Output is correct |
17 |
Correct |
4 ms |
4204 KB |
Output is correct |
18 |
Correct |
4 ms |
4204 KB |
Output is correct |
19 |
Correct |
4 ms |
4204 KB |
Output is correct |
20 |
Correct |
4 ms |
4204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4204 KB |
Output is correct |
2 |
Correct |
4 ms |
4204 KB |
Output is correct |
3 |
Correct |
4 ms |
4204 KB |
Output is correct |
4 |
Correct |
4 ms |
4204 KB |
Output is correct |
5 |
Correct |
4 ms |
4204 KB |
Output is correct |
6 |
Correct |
4 ms |
4204 KB |
Output is correct |
7 |
Correct |
4 ms |
4204 KB |
Output is correct |
8 |
Correct |
4 ms |
4204 KB |
Output is correct |
9 |
Correct |
4 ms |
4224 KB |
Output is correct |
10 |
Correct |
4 ms |
4204 KB |
Output is correct |
11 |
Correct |
4 ms |
4204 KB |
Output is correct |
12 |
Correct |
4 ms |
4204 KB |
Output is correct |
13 |
Correct |
4 ms |
4204 KB |
Output is correct |
14 |
Correct |
4 ms |
4224 KB |
Output is correct |
15 |
Correct |
4 ms |
4352 KB |
Output is correct |
16 |
Correct |
4 ms |
4204 KB |
Output is correct |
17 |
Correct |
4 ms |
4204 KB |
Output is correct |
18 |
Correct |
4 ms |
4204 KB |
Output is correct |
19 |
Correct |
4 ms |
4204 KB |
Output is correct |
20 |
Correct |
4 ms |
4204 KB |
Output is correct |
21 |
Correct |
4 ms |
4332 KB |
Output is correct |
22 |
Correct |
4 ms |
4332 KB |
Output is correct |
23 |
Correct |
4 ms |
4332 KB |
Output is correct |
24 |
Correct |
4 ms |
4332 KB |
Output is correct |
25 |
Correct |
4 ms |
4332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
5612 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
50 ms |
7020 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
54 ms |
7300 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4204 KB |
Output is correct |
2 |
Correct |
4 ms |
4204 KB |
Output is correct |
3 |
Correct |
4 ms |
4204 KB |
Output is correct |
4 |
Correct |
4 ms |
4204 KB |
Output is correct |
5 |
Correct |
4 ms |
4204 KB |
Output is correct |
6 |
Correct |
4 ms |
4204 KB |
Output is correct |
7 |
Correct |
4 ms |
4204 KB |
Output is correct |
8 |
Correct |
4 ms |
4204 KB |
Output is correct |
9 |
Correct |
4 ms |
4224 KB |
Output is correct |
10 |
Correct |
4 ms |
4204 KB |
Output is correct |
11 |
Incorrect |
32 ms |
5612 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4204 KB |
Output is correct |
2 |
Correct |
4 ms |
4204 KB |
Output is correct |
3 |
Correct |
4 ms |
4204 KB |
Output is correct |
4 |
Correct |
4 ms |
4204 KB |
Output is correct |
5 |
Correct |
4 ms |
4204 KB |
Output is correct |
6 |
Correct |
4 ms |
4204 KB |
Output is correct |
7 |
Correct |
4 ms |
4204 KB |
Output is correct |
8 |
Correct |
4 ms |
4204 KB |
Output is correct |
9 |
Correct |
4 ms |
4224 KB |
Output is correct |
10 |
Correct |
4 ms |
4204 KB |
Output is correct |
11 |
Correct |
4 ms |
4204 KB |
Output is correct |
12 |
Correct |
4 ms |
4204 KB |
Output is correct |
13 |
Correct |
4 ms |
4204 KB |
Output is correct |
14 |
Correct |
4 ms |
4224 KB |
Output is correct |
15 |
Correct |
4 ms |
4352 KB |
Output is correct |
16 |
Correct |
4 ms |
4204 KB |
Output is correct |
17 |
Correct |
4 ms |
4204 KB |
Output is correct |
18 |
Correct |
4 ms |
4204 KB |
Output is correct |
19 |
Correct |
4 ms |
4204 KB |
Output is correct |
20 |
Correct |
4 ms |
4204 KB |
Output is correct |
21 |
Correct |
4 ms |
4332 KB |
Output is correct |
22 |
Correct |
4 ms |
4332 KB |
Output is correct |
23 |
Correct |
4 ms |
4332 KB |
Output is correct |
24 |
Correct |
4 ms |
4332 KB |
Output is correct |
25 |
Correct |
4 ms |
4332 KB |
Output is correct |
26 |
Incorrect |
32 ms |
5612 KB |
Output isn't correct |
27 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4204 KB |
Output is correct |
2 |
Correct |
4 ms |
4204 KB |
Output is correct |
3 |
Correct |
4 ms |
4204 KB |
Output is correct |
4 |
Correct |
4 ms |
4204 KB |
Output is correct |
5 |
Correct |
4 ms |
4204 KB |
Output is correct |
6 |
Correct |
4 ms |
4204 KB |
Output is correct |
7 |
Correct |
4 ms |
4204 KB |
Output is correct |
8 |
Correct |
4 ms |
4204 KB |
Output is correct |
9 |
Correct |
4 ms |
4224 KB |
Output is correct |
10 |
Correct |
4 ms |
4204 KB |
Output is correct |
11 |
Correct |
4 ms |
4204 KB |
Output is correct |
12 |
Correct |
4 ms |
4204 KB |
Output is correct |
13 |
Correct |
4 ms |
4204 KB |
Output is correct |
14 |
Correct |
4 ms |
4224 KB |
Output is correct |
15 |
Correct |
4 ms |
4352 KB |
Output is correct |
16 |
Correct |
4 ms |
4204 KB |
Output is correct |
17 |
Correct |
4 ms |
4204 KB |
Output is correct |
18 |
Correct |
4 ms |
4204 KB |
Output is correct |
19 |
Correct |
4 ms |
4204 KB |
Output is correct |
20 |
Correct |
4 ms |
4204 KB |
Output is correct |
21 |
Correct |
4 ms |
4332 KB |
Output is correct |
22 |
Correct |
4 ms |
4332 KB |
Output is correct |
23 |
Correct |
4 ms |
4332 KB |
Output is correct |
24 |
Correct |
4 ms |
4332 KB |
Output is correct |
25 |
Correct |
4 ms |
4332 KB |
Output is correct |
26 |
Incorrect |
32 ms |
5612 KB |
Output isn't correct |
27 |
Halted |
0 ms |
0 KB |
- |