답안 #689777

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
689777 2023-01-29T11:03:36 Z zeroesandones Pilot (NOI19_pilot) C++17
55 / 100
1000 ms 2508 KB
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll, ll> pi;

#define FOR(i, j, k) for (ll i = j; i < (ll) k; ++i)
#define FORD(i, j, k) for (ll i = j; i >= (ll) k; --i)
#define nl "\n"
#define sp " "

#define all(x) (x).begin(), (x).end()
#define sc second
#define fr first
#define pb emplace_back

struct UFDS {
    vi link, sz;
    int n;

    UFDS(int N) {
        init(N);
    }

    void init(int N) {
        n = N;
        link = vi(n);
        iota(all(link), 0);
        sz = vi(n, 1);
    }

    ll find(ll x) {
        return (link[x] == x ? x : link[x] = find(link[x]));
    }

    void unite(ll a, ll b) {
        a = find(a);
        b = find(b);
        if(a == b) return;
        if(sz[a] < sz[b]) swap(a, b);

        sz[a] += sz[b];
        link[b] = a;
    }

    bool same(ll a, ll b){
        return (find(a) == find(b));
    }
};

void solve()
{
    ll n, q;
    cin >> n >> q;

    ll a[n];
    FOR(i, 0, n) {
        cin >> a[i];
    }

    while(q--) {
        ll x;
        cin >> x;

        ll ans = 0;
        ll curr = 0;
        FOR(i, 0, n) {
            if(a[i] > x)
                curr = 0;
            else
                ++curr;
            ans += curr;
        }
        cout << ans << nl;
    }
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 328 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 320 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 328 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 320 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 328 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 320 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 3 ms 336 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 3 ms 352 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 1632 KB Output is correct
2 Correct 8 ms 1708 KB Output is correct
3 Correct 7 ms 1492 KB Output is correct
4 Correct 7 ms 1620 KB Output is correct
5 Correct 7 ms 1552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1066 ms 2120 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1071 ms 2508 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 328 KB Output is correct
11 Correct 7 ms 1632 KB Output is correct
12 Correct 8 ms 1708 KB Output is correct
13 Correct 7 ms 1492 KB Output is correct
14 Correct 7 ms 1620 KB Output is correct
15 Correct 7 ms 1552 KB Output is correct
16 Correct 7 ms 1576 KB Output is correct
17 Correct 8 ms 1620 KB Output is correct
18 Correct 8 ms 1724 KB Output is correct
19 Correct 7 ms 1564 KB Output is correct
20 Correct 8 ms 1620 KB Output is correct
21 Correct 7 ms 1484 KB Output is correct
22 Correct 9 ms 1620 KB Output is correct
23 Correct 7 ms 1596 KB Output is correct
24 Correct 7 ms 1620 KB Output is correct
25 Correct 8 ms 1620 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 328 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 320 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 3 ms 336 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 3 ms 352 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 7 ms 1632 KB Output is correct
27 Correct 8 ms 1708 KB Output is correct
28 Correct 7 ms 1492 KB Output is correct
29 Correct 7 ms 1620 KB Output is correct
30 Correct 7 ms 1552 KB Output is correct
31 Execution timed out 1066 ms 2120 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 324 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 0 ms 328 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 0 ms 320 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 1 ms 212 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 1 ms 324 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 2 ms 340 KB Output is correct
22 Correct 3 ms 336 KB Output is correct
23 Correct 3 ms 340 KB Output is correct
24 Correct 3 ms 352 KB Output is correct
25 Correct 2 ms 340 KB Output is correct
26 Correct 7 ms 1632 KB Output is correct
27 Correct 8 ms 1708 KB Output is correct
28 Correct 7 ms 1492 KB Output is correct
29 Correct 7 ms 1620 KB Output is correct
30 Correct 7 ms 1552 KB Output is correct
31 Execution timed out 1066 ms 2120 KB Time limit exceeded
32 Halted 0 ms 0 KB -