Submission #547973

#TimeUsernameProblemLanguageResultExecution timeMemory
547973Jarif_Rahman Martian DNA (BOI18_dna)C++17
100 / 100
147 ms137676 KiB
#include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n, k, r; cin >> n >> k >> r; vector<int> v(n); for(int &x: v) cin >> x; vector<queue<int>> sth(k); vector<int> req(k, 0); for(int i = 0; i < r; i++){ int b, q; cin >> b >> q; req[b] = q; } int tbo = r; set<int> ss; int ans = 1e9; for(int i = 0; i < n; i++){ if(sth[v[i]].size() < req[v[i]]){ sth[v[i]].push(i); ss.insert(i); if(sth[v[i]].size() == req[v[i]]) tbo--; } else if(req[v[i]] != 0){ sth[v[i]].push(i); ss.insert(i); ss.erase(sth[v[i]].front()); sth[v[i]].pop(); } if(tbo == 0) ans = min(ans, i-*ss.begin()+1); } if(ans > n) cout << "impossible\n"; else cout << ans << "\n"; }

Compilation message (stderr)

dna.cpp: In function 'int main()':
dna.cpp:31:29: warning: comparison of integer expressions of different signedness: 'std::queue<int>::size_type' {aka 'long unsigned int'} and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} [-Wsign-compare]
   31 |         if(sth[v[i]].size() < req[v[i]]){
dna.cpp:34:33: warning: comparison of integer expressions of different signedness: 'std::queue<int>::size_type' {aka 'long unsigned int'} and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} [-Wsign-compare]
   34 |             if(sth[v[i]].size() == req[v[i]]) tbo--;
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...