제출 #1025555

#제출 시각아이디문제언어결과실행 시간메모리
1025555kaysan Martian DNA (BOI18_dna)C++17
100 / 100
429 ms42404 KiB
#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; }

컴파일 시 표준 에러 (stderr) 메시지

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...