# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1111277 |
2024-11-12T01:14:05 Z |
TVSown |
Martian DNA (BOI18_dna) |
C++17 |
|
22 ms |
9020 KB |
///*** Sown_Vipro ***///
/// ->NHI QUOC GIA<- ///
#include<bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("popcnt")
#define F first
#define S second
#define pb push_back
#define pi pair<int, int>
#define pii pair<int, pair<int, int> >
#define FOR(i, a, b) for(int i = a; i <= b; ++i)
#define REP(i, a, b) for(int i = a; i >= b; --i)
#define all(s) s.begin(), s.end()
#define szz(s) (s.size())
const string NAME = "sown";
const int N = 1e6 + 5, MAX = 1e6, oo = 1e9 + 5, MOD = 1e9 + 7;
void maxi(int &x, int y){ if(x < y) x = y; }
void mini(int &x, int y){ if(x > y) x = y; };
void add(int &x, int y){ x += y; x += MOD * (x < 0); x -= MOD * (x >= MOD); };
int n, k, r, res;
int c[N], d[N], a[N];
void solve(){
cin >> n >> k >> r;
FOR(i, 1, n){
cin >> a[i];
}
int i = 1, j = 1;
FOR(j, 1, r){
int b, q; cin >> b >> q;
c[b] = q;
while(i <= n + 1 && d[b] < c[b]){
++d[a[i]];
++i;
}
}
if(i > n + 1){
cout << "impossible"; return;
}
while(d[a[j]] > c[a[j]]){
--d[a[j]]; ++j;
}
res = i - j;
for(i; i <= n; ++i){
++d[a[i]];
while(d[a[j]] > c[a[j]]){
--d[a[j]]; ++j;
}
res = min(res, i - j + 1);
}
cout << res;
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
// if(fopen((NAME + ".inp").c_str(), "r")){
// freopen((NAME + ".inp").c_str(), "r", stdin);
// freopen((NAME + ".out").c_str(), "w", stdout);
// }
int t = 1;
// cin >> t;
while(t--){
solve();
}
}
Compilation message
dna.cpp: In function 'void solve()':
dna.cpp:47:9: warning: statement has no effect [-Wunused-value]
47 | for(i; i <= n; ++i){
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2384 KB |
Output is correct |
2 |
Correct |
1 ms |
2384 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
1 ms |
2384 KB |
Output is correct |
5 |
Correct |
1 ms |
2384 KB |
Output is correct |
6 |
Correct |
1 ms |
2556 KB |
Output is correct |
7 |
Correct |
1 ms |
2560 KB |
Output is correct |
8 |
Correct |
1 ms |
2384 KB |
Output is correct |
9 |
Correct |
1 ms |
2384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2384 KB |
Output is correct |
2 |
Correct |
2 ms |
2384 KB |
Output is correct |
3 |
Correct |
1 ms |
2384 KB |
Output is correct |
4 |
Correct |
1 ms |
2808 KB |
Output is correct |
5 |
Correct |
1 ms |
2384 KB |
Output is correct |
6 |
Correct |
1 ms |
2384 KB |
Output is correct |
7 |
Correct |
1 ms |
2384 KB |
Output is correct |
8 |
Correct |
1 ms |
2384 KB |
Output is correct |
9 |
Correct |
1 ms |
2384 KB |
Output is correct |
10 |
Correct |
1 ms |
2384 KB |
Output is correct |
11 |
Correct |
1 ms |
2552 KB |
Output is correct |
12 |
Correct |
1 ms |
2384 KB |
Output is correct |
13 |
Correct |
1 ms |
2384 KB |
Output is correct |
14 |
Correct |
1 ms |
2384 KB |
Output is correct |
15 |
Correct |
1 ms |
2384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
4688 KB |
Output is correct |
2 |
Correct |
9 ms |
4688 KB |
Output is correct |
3 |
Correct |
11 ms |
4688 KB |
Output is correct |
4 |
Correct |
10 ms |
4624 KB |
Output is correct |
5 |
Correct |
12 ms |
4944 KB |
Output is correct |
6 |
Correct |
9 ms |
4688 KB |
Output is correct |
7 |
Correct |
10 ms |
1104 KB |
Output is correct |
8 |
Correct |
15 ms |
1872 KB |
Output is correct |
9 |
Correct |
11 ms |
4688 KB |
Output is correct |
10 |
Correct |
8 ms |
4688 KB |
Output is correct |
11 |
Correct |
1 ms |
2384 KB |
Output is correct |
12 |
Correct |
1 ms |
2384 KB |
Output is correct |
13 |
Correct |
1 ms |
2384 KB |
Output is correct |
14 |
Correct |
1 ms |
2384 KB |
Output is correct |
15 |
Correct |
1 ms |
2432 KB |
Output is correct |
16 |
Correct |
1 ms |
2384 KB |
Output is correct |
17 |
Correct |
1 ms |
2384 KB |
Output is correct |
18 |
Correct |
1 ms |
2384 KB |
Output is correct |
19 |
Correct |
1 ms |
2384 KB |
Output is correct |
20 |
Correct |
1 ms |
2384 KB |
Output is correct |
21 |
Correct |
1 ms |
2384 KB |
Output is correct |
22 |
Correct |
1 ms |
2384 KB |
Output is correct |
23 |
Correct |
1 ms |
2384 KB |
Output is correct |
24 |
Correct |
1 ms |
2384 KB |
Output is correct |
25 |
Correct |
1 ms |
2552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
4944 KB |
Output is correct |
2 |
Correct |
18 ms |
5684 KB |
Output is correct |
3 |
Correct |
15 ms |
5968 KB |
Output is correct |
4 |
Correct |
9 ms |
4688 KB |
Output is correct |
5 |
Correct |
19 ms |
6992 KB |
Output is correct |
6 |
Correct |
22 ms |
9020 KB |
Output is correct |
7 |
Correct |
12 ms |
5368 KB |
Output is correct |
8 |
Correct |
14 ms |
5168 KB |
Output is correct |
9 |
Correct |
13 ms |
4944 KB |
Output is correct |
10 |
Correct |
10 ms |
4688 KB |
Output is correct |
11 |
Correct |
10 ms |
2700 KB |
Output is correct |
12 |
Correct |
9 ms |
2640 KB |
Output is correct |
13 |
Correct |
12 ms |
5076 KB |
Output is correct |
14 |
Correct |
9 ms |
4944 KB |
Output is correct |
15 |
Correct |
10 ms |
4688 KB |
Output is correct |
16 |
Correct |
14 ms |
3376 KB |
Output is correct |
17 |
Correct |
12 ms |
3288 KB |
Output is correct |
18 |
Correct |
9 ms |
5112 KB |
Output is correct |
19 |
Correct |
1 ms |
2384 KB |
Output is correct |
20 |
Correct |
1 ms |
336 KB |
Output is correct |
21 |
Correct |
1 ms |
336 KB |
Output is correct |
22 |
Correct |
1 ms |
336 KB |
Output is correct |
23 |
Correct |
1 ms |
504 KB |
Output is correct |
24 |
Correct |
1 ms |
336 KB |
Output is correct |
25 |
Correct |
1 ms |
760 KB |
Output is correct |
26 |
Correct |
1 ms |
336 KB |
Output is correct |
27 |
Correct |
1 ms |
504 KB |
Output is correct |
28 |
Correct |
1 ms |
336 KB |
Output is correct |
29 |
Correct |
1 ms |
336 KB |
Output is correct |
30 |
Correct |
1 ms |
336 KB |
Output is correct |
31 |
Correct |
1 ms |
348 KB |
Output is correct |
32 |
Correct |
1 ms |
336 KB |
Output is correct |
33 |
Correct |
1 ms |
336 KB |
Output is correct |