Submission #1060290

# Submission time Handle Problem Language Result Execution time Memory
1060290 2024-08-15T12:40:03 Z aymanrs Sličnost (COI23_slicnost) C++17
24 / 100
3000 ms 2392 KB
#include<bits/stdc++.h>
using namespace std;
void ans(int n, int a[],int b[], int k){
    bool s[n+1] = {false};
    for(int i = 0;i < k;i++) s[a[i]] = true;
    int tans = -1, co = 0;
    for(int i = 0;i+k <= n;i++){
        if(i) {
            s[a[i-1]]=false;
            s[a[i+k-1]] = true;
        }
        int t = 0;
        for(int j = 0;j < k;j++) t += s[b[j]];
        if(t>tans){
            tans = t;co=1;
        } else if(t == tans) co++;
        for(int j = 1;j+k <= n;j++){
            t -= s[b[j-1]];
            t += s[b[j+k-1]];
            if(t>tans){
                tans = t;co=1;
            } else if(t == tans) co++;
        }
    }
    cout << tans << ' ' << co << '\n';
}
void solve(){
    int n, k ,q;cin >> n >> k >> q;
    int a[n],b[n];
    for(int i = 0;i < n;i++) cin >> a[i];
    for(int i = 0;i < n;i++) cin >> b[i];
    ans(n, a, b, k);
    while(q--){
        int p;cin >> p;
        p--;
        swap(a[p], a[p+1]);
        ans(n,a,b,k);
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 25 ms 348 KB Output is correct
17 Correct 26 ms 536 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 9 ms 348 KB Output is correct
20 Correct 25 ms 348 KB Output is correct
21 Correct 22 ms 540 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 23 ms 348 KB Output is correct
24 Correct 24 ms 540 KB Output is correct
25 Correct 12 ms 544 KB Output is correct
26 Correct 15 ms 348 KB Output is correct
27 Correct 21 ms 348 KB Output is correct
28 Correct 12 ms 348 KB Output is correct
29 Correct 7 ms 348 KB Output is correct
30 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 25 ms 348 KB Output is correct
17 Correct 26 ms 536 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 9 ms 348 KB Output is correct
20 Correct 25 ms 348 KB Output is correct
21 Correct 22 ms 540 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 23 ms 348 KB Output is correct
24 Correct 24 ms 540 KB Output is correct
25 Correct 12 ms 544 KB Output is correct
26 Correct 15 ms 348 KB Output is correct
27 Correct 21 ms 348 KB Output is correct
28 Correct 12 ms 348 KB Output is correct
29 Correct 7 ms 348 KB Output is correct
30 Correct 2 ms 348 KB Output is correct
31 Execution timed out 3031 ms 2392 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 2 ms 452 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 1 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 1 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 25 ms 348 KB Output is correct
17 Correct 26 ms 536 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 9 ms 348 KB Output is correct
20 Correct 25 ms 348 KB Output is correct
21 Correct 22 ms 540 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 23 ms 348 KB Output is correct
24 Correct 24 ms 540 KB Output is correct
25 Correct 12 ms 544 KB Output is correct
26 Correct 15 ms 348 KB Output is correct
27 Correct 21 ms 348 KB Output is correct
28 Correct 12 ms 348 KB Output is correct
29 Correct 7 ms 348 KB Output is correct
30 Correct 2 ms 348 KB Output is correct
31 Correct 2 ms 452 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 1 ms 348 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 1 ms 348 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Execution timed out 3052 ms 512 KB Time limit exceeded
47 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 344 KB Output is correct
14 Correct 0 ms 344 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 25 ms 348 KB Output is correct
17 Correct 26 ms 536 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 9 ms 348 KB Output is correct
20 Correct 25 ms 348 KB Output is correct
21 Correct 22 ms 540 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 23 ms 348 KB Output is correct
24 Correct 24 ms 540 KB Output is correct
25 Correct 12 ms 544 KB Output is correct
26 Correct 15 ms 348 KB Output is correct
27 Correct 21 ms 348 KB Output is correct
28 Correct 12 ms 348 KB Output is correct
29 Correct 7 ms 348 KB Output is correct
30 Correct 2 ms 348 KB Output is correct
31 Execution timed out 3031 ms 2392 KB Time limit exceeded
32 Halted 0 ms 0 KB -