# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
675954 | 2022-12-28T15:07:00 Z | guagua0407 | Martian DNA (BOI18_dna) | C++17 | 249 ms | 13440 KB |
/* 燒雞 燒雞 燒雞 好想進選訓 燒雞 燒雞 */ #pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int,int> #define f first #define s second #define all(x) x.begin(),x.end() #define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } const int mxn=2e5+5; int num[mxn]; map<int,int> mp; vector<int> cntr(mxn,0); vector<bool> isenough(mxn,false); set<int> have; int n; int main() {_ //setIO("wayne"); int k,R; cin>>n>>k>>R; for(int i=1;i<=n;i++){ cin>>num[i]; } for(int i=0;i<R;i++){ int x,cnt; cin>>x>>cnt; mp[x]=cnt; have.insert(x); } int ans=n+1; int r=0; int cur=0; for(int l=1;l<=n;l++){ while(cur<R and r+1<=n){ r++; if(have.count(num[r])){ cntr[num[r]]++; if(cntr[num[r]]>=mp[num[r]]){ if(isenough[num[r]]==false){ cur++; } isenough[num[r]]=true; } } if(r==n) break; } if(cur>=R){ ans=min(ans,r-l+1); } if(have.count(num[l])==0) continue; cntr[num[l]]--; if(cntr[num[l]]<mp[num[l]]){ if(isenough[num[l]]==true){ cur--; } isenough[num[l]]=false; } } if(ans==n+1){ cout<<"impossible"; } else{ cout<<ans; } return 0; } //maybe its multiset not set
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1108 KB | Output is correct |
2 | Correct | 1 ms | 1108 KB | Output is correct |
3 | Correct | 1 ms | 1108 KB | Output is correct |
4 | Correct | 1 ms | 1108 KB | Output is correct |
5 | Correct | 1 ms | 1108 KB | Output is correct |
6 | Correct | 1 ms | 1108 KB | Output is correct |
7 | Correct | 1 ms | 1108 KB | Output is correct |
8 | Correct | 1 ms | 1108 KB | Output is correct |
9 | Correct | 1 ms | 1108 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1156 KB | Output is correct |
2 | Correct | 1 ms | 1108 KB | Output is correct |
3 | Correct | 1 ms | 1108 KB | Output is correct |
4 | Correct | 1 ms | 1108 KB | Output is correct |
5 | Correct | 1 ms | 1108 KB | Output is correct |
6 | Correct | 1 ms | 1108 KB | Output is correct |
7 | Correct | 1 ms | 1108 KB | Output is correct |
8 | Correct | 1 ms | 1108 KB | Output is correct |
9 | Correct | 1 ms | 1108 KB | Output is correct |
10 | Correct | 2 ms | 1108 KB | Output is correct |
11 | Correct | 1 ms | 1108 KB | Output is correct |
12 | Correct | 1 ms | 1108 KB | Output is correct |
13 | Correct | 1 ms | 1108 KB | Output is correct |
14 | Correct | 1 ms | 1108 KB | Output is correct |
15 | Correct | 1 ms | 1108 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 2260 KB | Output is correct |
2 | Correct | 15 ms | 2316 KB | Output is correct |
3 | Correct | 16 ms | 2316 KB | Output is correct |
4 | Correct | 16 ms | 2304 KB | Output is correct |
5 | Correct | 21 ms | 3020 KB | Output is correct |
6 | Correct | 21 ms | 2232 KB | Output is correct |
7 | Correct | 20 ms | 2572 KB | Output is correct |
8 | Correct | 23 ms | 3148 KB | Output is correct |
9 | Correct | 20 ms | 2764 KB | Output is correct |
10 | Correct | 20 ms | 2248 KB | Output is correct |
11 | Correct | 1 ms | 1108 KB | Output is correct |
12 | Correct | 1 ms | 1108 KB | Output is correct |
13 | Correct | 1 ms | 1108 KB | Output is correct |
14 | Correct | 1 ms | 1108 KB | Output is correct |
15 | Correct | 1 ms | 1168 KB | Output is correct |
16 | Correct | 1 ms | 1108 KB | Output is correct |
17 | Correct | 1 ms | 1108 KB | Output is correct |
18 | Correct | 1 ms | 1108 KB | Output is correct |
19 | Correct | 1 ms | 1108 KB | Output is correct |
20 | Correct | 1 ms | 1108 KB | Output is correct |
21 | Correct | 1 ms | 1108 KB | Output is correct |
22 | Correct | 1 ms | 1108 KB | Output is correct |
23 | Correct | 1 ms | 1108 KB | Output is correct |
24 | Correct | 1 ms | 1108 KB | Output is correct |
25 | Correct | 1 ms | 1108 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 203 ms | 11056 KB | Output is correct |
2 | Correct | 154 ms | 9108 KB | Output is correct |
3 | Correct | 86 ms | 4968 KB | Output is correct |
4 | Correct | 17 ms | 2280 KB | Output is correct |
5 | Correct | 215 ms | 11516 KB | Output is correct |
6 | Correct | 249 ms | 13440 KB | Output is correct |
7 | Correct | 92 ms | 3516 KB | Output is correct |
8 | Correct | 113 ms | 4556 KB | Output is correct |
9 | Correct | 17 ms | 2296 KB | Output is correct |
10 | Correct | 15 ms | 2308 KB | Output is correct |
11 | Correct | 19 ms | 2356 KB | Output is correct |
12 | Correct | 16 ms | 2304 KB | Output is correct |
13 | Correct | 21 ms | 2972 KB | Output is correct |
14 | Correct | 21 ms | 2260 KB | Output is correct |
15 | Correct | 17 ms | 2448 KB | Output is correct |
16 | Correct | 23 ms | 3156 KB | Output is correct |
17 | Correct | 20 ms | 2828 KB | Output is correct |
18 | Correct | 20 ms | 2292 KB | Output is correct |
19 | Correct | 1 ms | 1108 KB | Output is correct |
20 | Correct | 1 ms | 1236 KB | Output is correct |
21 | Correct | 1 ms | 1180 KB | Output is correct |
22 | Correct | 1 ms | 1184 KB | Output is correct |
23 | Correct | 1 ms | 1108 KB | Output is correct |
24 | Correct | 1 ms | 1108 KB | Output is correct |
25 | Correct | 1 ms | 1108 KB | Output is correct |
26 | Correct | 1 ms | 1108 KB | Output is correct |
27 | Correct | 1 ms | 1108 KB | Output is correct |
28 | Correct | 1 ms | 1108 KB | Output is correct |
29 | Correct | 1 ms | 1108 KB | Output is correct |
30 | Correct | 1 ms | 1108 KB | Output is correct |
31 | Correct | 1 ms | 1108 KB | Output is correct |
32 | Correct | 1 ms | 1108 KB | Output is correct |
33 | Correct | 1 ms | 1108 KB | Output is correct |