# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1013780 |
2024-07-04T05:47:04 Z |
vjudge1 |
Martian DNA (BOI18_dna) |
C++17 |
|
19 ms |
2908 KB |
#include <bits/stdc++.h>
#include <fstream>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define endl '\n'
#define mod 1000000007
#define INF 1000000000
#define INF2 2000000000
#define fi first
#define se second
using namespace std;
double const EPS = 1e-14;
const int P = 100780807;
typedef long long ll;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order, order_of_key
const int N = 2e5 + 5;
int arr[N], e[N], cnt[N];
bool ok[N];
int main()
{
ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
int n, k, m; cin >> n >> k >> m;
for(int i = 0; i < n; i++) cin >> arr[i];
int cur = m;
for(int i = 0; i < m; i++) {
int a, b; cin >> a >> b;
e[a] = b;
ok[a] = 1;
}
int l = 0, r = 0;
int ans = INF;
while(r <= n) {
if(cur == 0) {
ans = min(ans,(r-l));
cnt[arr[l]]--;
if(cnt[arr[l]]+1 == e[arr[l]] && ok[arr[l]] == 1) cur++;
l++;
}
else {
if(r >= n) break;
cnt[arr[r]]++;
if(cnt[arr[r]] == e[arr[r]] && ok[arr[r]] == 1) cur--;
r++;
}
}
(ans == INF ? cout << "impossible" << endl : cout << ans << endl);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
2396 KB |
Output is correct |
3 |
Correct |
0 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2516 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2396 KB |
Output is correct |
4 |
Correct |
1 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2396 KB |
Output is correct |
6 |
Correct |
0 ms |
2396 KB |
Output is correct |
7 |
Correct |
0 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2396 KB |
Output is correct |
9 |
Correct |
0 ms |
2396 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
0 ms |
2396 KB |
Output is correct |
14 |
Correct |
0 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
8 ms |
2648 KB |
Output is correct |
2 |
Correct |
8 ms |
2652 KB |
Output is correct |
3 |
Correct |
8 ms |
2652 KB |
Output is correct |
4 |
Correct |
8 ms |
2652 KB |
Output is correct |
5 |
Correct |
11 ms |
2652 KB |
Output is correct |
6 |
Correct |
9 ms |
2652 KB |
Output is correct |
7 |
Correct |
8 ms |
2776 KB |
Output is correct |
8 |
Correct |
12 ms |
2652 KB |
Output is correct |
9 |
Correct |
9 ms |
2652 KB |
Output is correct |
10 |
Correct |
8 ms |
2652 KB |
Output is correct |
11 |
Correct |
1 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
1 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
0 ms |
2396 KB |
Output is correct |
19 |
Correct |
0 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
0 ms |
2396 KB |
Output is correct |
23 |
Correct |
1 ms |
2396 KB |
Output is correct |
24 |
Correct |
0 ms |
2396 KB |
Output is correct |
25 |
Correct |
0 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
17 ms |
2648 KB |
Output is correct |
2 |
Correct |
17 ms |
2888 KB |
Output is correct |
3 |
Correct |
13 ms |
2652 KB |
Output is correct |
4 |
Correct |
7 ms |
2652 KB |
Output is correct |
5 |
Correct |
18 ms |
2908 KB |
Output is correct |
6 |
Correct |
19 ms |
2904 KB |
Output is correct |
7 |
Correct |
10 ms |
2652 KB |
Output is correct |
8 |
Correct |
10 ms |
2652 KB |
Output is correct |
9 |
Correct |
6 ms |
2600 KB |
Output is correct |
10 |
Correct |
7 ms |
2652 KB |
Output is correct |
11 |
Correct |
7 ms |
2588 KB |
Output is correct |
12 |
Correct |
7 ms |
2652 KB |
Output is correct |
13 |
Correct |
12 ms |
2772 KB |
Output is correct |
14 |
Correct |
6 ms |
2652 KB |
Output is correct |
15 |
Correct |
8 ms |
2652 KB |
Output is correct |
16 |
Correct |
11 ms |
2652 KB |
Output is correct |
17 |
Correct |
9 ms |
2648 KB |
Output is correct |
18 |
Correct |
7 ms |
2800 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
1 ms |
2392 KB |
Output is correct |
24 |
Correct |
1 ms |
2396 KB |
Output is correct |
25 |
Correct |
0 ms |
2396 KB |
Output is correct |
26 |
Correct |
0 ms |
2396 KB |
Output is correct |
27 |
Correct |
1 ms |
2396 KB |
Output is correct |
28 |
Correct |
0 ms |
2396 KB |
Output is correct |
29 |
Correct |
1 ms |
2396 KB |
Output is correct |
30 |
Correct |
0 ms |
2396 KB |
Output is correct |
31 |
Correct |
0 ms |
2396 KB |
Output is correct |
32 |
Correct |
0 ms |
2396 KB |
Output is correct |
33 |
Correct |
0 ms |
2396 KB |
Output is correct |