Submission #1025396

# Submission time Handle Problem Language Result Execution time Memory
1025396 2024-07-17T01:31:19 Z vjudge1 Martian DNA (BOI18_dna) C++17
100 / 100
433 ms 42576 KB
#include <bits/stdc++.h>
#define ll long long
#define nikah ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll maxn = 2e5+7;
using namespace std;

ll n,k,p;
ll a[maxn];
map<ll,ll>m,m1,m2;
set<ll>s;

int main () {
	nikah
	cin>>n>>k>>p;
	for (ll i=1; i<=n; i++) {
		cin>>a[i];
		m1[a[i]]++;
	}
	bool cek = 0;
	for (ll i=1; i<=p; i++) {
		ll x,y; cin>>x>>y;
		m[x] = y;
	}
	ll l = 1, r = 1, ans = 1e18;
	while (r <= n) {
		m2[a[r]]++;
		if (m2[a[r]] == m[a[r]] && m[a[r]] != 0) {
			s.insert(a[r]);
		}
		if (s.size() == p) {
			while (l <= r) {
				if (m2[a[l]] == m[a[l]]) {
					break;
				}
				m2[a[l]]--;
				l++;
			}
			ans = min(ans, r - l + 1);
			m2[a[l]]--;
			s.erase(a[l]);
			l++;
		}
	//	cout<<m2[a[r]]<<" ";
		r++;
	}
	if (ans == 1e18) cout<<"impossible"<<endl;
	else cout<<ans<<endl;
}

Compilation message

dna.cpp: In function 'int main()':
dna.cpp:30:16: warning: comparison of integer expressions of different signedness: 'std::set<long long int>::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   30 |   if (s.size() == p) {
      |       ~~~~~~~~~^~~~
dna.cpp:19:7: warning: unused variable 'cek' [-Wunused-variable]
   19 |  bool cek = 0;
      |       ^~~
# 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 1 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
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 2 ms 856 KB Output is correct
4 Correct 3 ms 1116 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 1 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 1 ms 348 KB Output is correct
13 Correct 0 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 13 ms 1900 KB Output is correct
2 Correct 12 ms 2392 KB Output is correct
3 Correct 18 ms 2460 KB Output is correct
4 Correct 15 ms 2396 KB Output is correct
5 Correct 185 ms 18048 KB Output is correct
6 Correct 15 ms 2392 KB Output is correct
7 Correct 23 ms 2512 KB Output is correct
8 Correct 292 ms 40664 KB Output is correct
9 Correct 111 ms 4376 KB Output is correct
10 Correct 17 ms 2396 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 2 ms 860 KB Output is correct
14 Correct 4 ms 1116 KB Output is correct
15 Correct 2 ms 604 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 355 ms 20576 KB Output is correct
2 Correct 275 ms 17488 KB Output is correct
3 Correct 210 ms 15448 KB Output is correct
4 Correct 18 ms 2392 KB Output is correct
5 Correct 220 ms 22868 KB Output is correct
6 Correct 433 ms 42576 KB Output is correct
7 Correct 95 ms 4796 KB Output is correct
8 Correct 158 ms 7508 KB Output is correct
9 Correct 13 ms 2396 KB Output is correct
10 Correct 12 ms 2396 KB Output is correct
11 Correct 18 ms 2392 KB Output is correct
12 Correct 15 ms 2272 KB Output is correct
13 Correct 178 ms 18260 KB Output is correct
14 Correct 13 ms 2396 KB Output is correct
15 Correct 24 ms 2448 KB Output is correct
16 Correct 285 ms 40788 KB Output is correct
17 Correct 109 ms 4440 KB Output is correct
18 Correct 17 ms 2396 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 0 ms 348 KB Output is correct
21 Correct 2 ms 860 KB Output is correct
22 Correct 3 ms 1120 KB Output is correct
23 Correct 2 ms 604 KB Output is correct
24 Correct 1 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct