답안 #867789

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
867789 2023-10-29T13:16:40 Z sleepntsheep Pilot (NOI19_pilot) C++14
18 / 100
59 ms 14160 KB
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <deque>
#include <set>
#include <utility>
#include <array>

using namespace std;
#define ALL(x) x.begin(), x.end()
#define ShinLena cin.tie(nullptr)->sync_with_stdio(false);
using ll = long long;
#define N 1000005

int n, q;
array<int, 2> a[N], b[N];
set<int> s;
ll z, c[N];
ll C2(ll x) { return x*(x+1)/2; }

int main()
{
    ShinLena;
    cin >> n >> q;
    for (int i = 0; i < n; ++i) cin >> a[i][0], a[i][1] = i;
    for (int i = 0; i < q; ++i) cin >> b[i][0], b[i][1] = i;
    sort(a, a+n);
    sort(b, b+q);
    s.emplace(-1); s.emplace(n); z = C2(n);
    for (int i = q, j = n - 1; i--;)
    {
        for (; j >= 0 && a[j][0] > b[i][0]; --j)
        {
            auto it = s.upper_bound(a[j][1]);
            ll r = *it, l = *prev(it), w = (r-l-1), wl=a[j][1]-l-1, wr =r-a[j][1]-1;
            z += -C2(w) + C2(wl) + C2(wr);
            s.insert(a[j][1]);
        }
        c[i] = z;
    }
    for (int i = 0; i < q; ++i) cout << c[i] << '\n';


    return 0;
}


# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4596 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4596 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Incorrect 1 ms 4444 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4596 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Incorrect 1 ms 4444 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4596 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Incorrect 1 ms 4444 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 14 ms 4444 KB Output is correct
2 Correct 18 ms 5232 KB Output is correct
3 Correct 17 ms 4956 KB Output is correct
4 Correct 16 ms 4956 KB Output is correct
5 Correct 15 ms 4956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 50 ms 14160 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 59 ms 14140 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4596 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Correct 14 ms 4444 KB Output is correct
12 Correct 18 ms 5232 KB Output is correct
13 Correct 17 ms 4956 KB Output is correct
14 Correct 16 ms 4956 KB Output is correct
15 Correct 15 ms 4956 KB Output is correct
16 Correct 21 ms 6376 KB Output is correct
17 Correct 31 ms 8196 KB Output is correct
18 Correct 40 ms 9140 KB Output is correct
19 Correct 38 ms 8768 KB Output is correct
20 Correct 27 ms 7344 KB Output is correct
21 Correct 16 ms 4956 KB Output is correct
22 Correct 26 ms 7212 KB Output is correct
23 Correct 33 ms 8264 KB Output is correct
24 Correct 33 ms 8564 KB Output is correct
25 Correct 26 ms 7260 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4596 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Incorrect 1 ms 4444 KB Output isn't correct
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4596 KB Output is correct
2 Correct 1 ms 4444 KB Output is correct
3 Correct 1 ms 4444 KB Output is correct
4 Correct 1 ms 4444 KB Output is correct
5 Correct 1 ms 4444 KB Output is correct
6 Correct 1 ms 4444 KB Output is correct
7 Correct 1 ms 4444 KB Output is correct
8 Correct 1 ms 4444 KB Output is correct
9 Correct 1 ms 4444 KB Output is correct
10 Correct 1 ms 4444 KB Output is correct
11 Incorrect 1 ms 4444 KB Output isn't correct
12 Halted 0 ms 0 KB -