Submission #954501

# Submission time Handle Problem Language Result Execution time Memory
954501 2024-03-28T05:10:05 Z GrandTiger1729 Sličnost (COI23_slicnost) C++17
17 / 100
3000 ms 14528 KB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    cin.tie(0)->sync_with_stdio(0);
    int n, K, q;
    cin >> n >> K >> q;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        a[i]--;
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
        b[i]--;
    }
    vector<int> aa(n), bb(n);
    for (int i = 0; i < n; i++)
    {
        aa[a[i]] = i;
        bb[b[i]] = i;
    }
    vector<vector<int>> add(n + 1), del(n + 1);
    for (int i = 0; i < n; i++)
    {
        add[max(0, aa[i] - (K - 1)) + (K - 1)].push_back(i);
        del[min(n, aa[i] + K)].push_back(i);
    }
    long long ans = 0, cnt = 0;
    vector<long long> dd(n);
    for (int t = 0; t <= n; t++)
    {
        for (int id : add[t])
        {
            int l = max(0, bb[id] - (K - 1)) + (K - 1), r = min(n, bb[id] + K);
            for (int i = l; i < r; i++)
            {
                dd[i]++;
            }
        }
        for (int id : del[t])
        {
            int l = max(0, bb[id] - (K - 1)) + (K - 1), r = min(n, bb[id] + K);
            for (int i = l; i < r; i++)
            {
                dd[i]--;
            }
        }
        long long res = 0, cc = 0;
        for (int i = K - 1; i < n; i++)
        {
            if (res < dd[i])
            {
                res = dd[i];
                cc = 1;
            }
            else if (res == dd[i])
            {
                cc++;
            }
        }
        if (res > ans)
        {
            ans = res;
            cnt = cc;
        }
        else if (res == ans)
        {
            cnt += cc;
        }
    }
    cout << ans << ' ' << cnt << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 18 ms 1152 KB Output is correct
17 Correct 19 ms 1376 KB Output is correct
18 Correct 1 ms 860 KB Output is correct
19 Correct 15 ms 1036 KB Output is correct
20 Correct 19 ms 1116 KB Output is correct
21 Correct 18 ms 1116 KB Output is correct
22 Correct 3 ms 860 KB Output is correct
23 Correct 17 ms 1116 KB Output is correct
24 Correct 17 ms 1116 KB Output is correct
25 Correct 16 ms 860 KB Output is correct
26 Correct 17 ms 856 KB Output is correct
27 Correct 17 ms 1116 KB Output is correct
28 Correct 15 ms 1040 KB Output is correct
29 Correct 13 ms 856 KB Output is correct
30 Correct 4 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 18 ms 1152 KB Output is correct
17 Correct 19 ms 1376 KB Output is correct
18 Correct 1 ms 860 KB Output is correct
19 Correct 15 ms 1036 KB Output is correct
20 Correct 19 ms 1116 KB Output is correct
21 Correct 18 ms 1116 KB Output is correct
22 Correct 3 ms 860 KB Output is correct
23 Correct 17 ms 1116 KB Output is correct
24 Correct 17 ms 1116 KB Output is correct
25 Correct 16 ms 860 KB Output is correct
26 Correct 17 ms 856 KB Output is correct
27 Correct 17 ms 1116 KB Output is correct
28 Correct 15 ms 1040 KB Output is correct
29 Correct 13 ms 856 KB Output is correct
30 Correct 4 ms 860 KB Output is correct
31 Execution timed out 3017 ms 14528 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Incorrect 0 ms 348 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 18 ms 1152 KB Output is correct
17 Correct 19 ms 1376 KB Output is correct
18 Correct 1 ms 860 KB Output is correct
19 Correct 15 ms 1036 KB Output is correct
20 Correct 19 ms 1116 KB Output is correct
21 Correct 18 ms 1116 KB Output is correct
22 Correct 3 ms 860 KB Output is correct
23 Correct 17 ms 1116 KB Output is correct
24 Correct 17 ms 1116 KB Output is correct
25 Correct 16 ms 860 KB Output is correct
26 Correct 17 ms 856 KB Output is correct
27 Correct 17 ms 1116 KB Output is correct
28 Correct 15 ms 1040 KB Output is correct
29 Correct 13 ms 856 KB Output is correct
30 Correct 4 ms 860 KB Output is correct
31 Incorrect 0 ms 348 KB Output isn't correct
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 464 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 1 ms 344 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 18 ms 1152 KB Output is correct
17 Correct 19 ms 1376 KB Output is correct
18 Correct 1 ms 860 KB Output is correct
19 Correct 15 ms 1036 KB Output is correct
20 Correct 19 ms 1116 KB Output is correct
21 Correct 18 ms 1116 KB Output is correct
22 Correct 3 ms 860 KB Output is correct
23 Correct 17 ms 1116 KB Output is correct
24 Correct 17 ms 1116 KB Output is correct
25 Correct 16 ms 860 KB Output is correct
26 Correct 17 ms 856 KB Output is correct
27 Correct 17 ms 1116 KB Output is correct
28 Correct 15 ms 1040 KB Output is correct
29 Correct 13 ms 856 KB Output is correct
30 Correct 4 ms 860 KB Output is correct
31 Execution timed out 3017 ms 14528 KB Time limit exceeded
32 Halted 0 ms 0 KB -