Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- / C++ includes used for precompiling -*- C++ -*-
- 2
- 3 // Copyright (C) 2003-2013 Free Software Foundation, Inc.
- 4 //
- 5 // This file is part of the GNU ISO C++ Library. This library is free
- 6 // software; you can redistribute it and/or modify it under the
- 7 // terms of the GNU General Public License as published by the
- 8 // Free Software Foundation; either version 3, or (at your option)
- 9 // any later version.
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- map<int, int>m;
- int n, k;
- cin>>n>>k;
- int a[n];
- for(int i = 0; i < n; i++){
- cin>>a[i];
- }
- for(int i = 0; i < k; i++){
- m[a[i]]++;
- }
- int l = 0, r = k - 1;
- while(r < n){
- cout<<m.begin()->first<<" ";
- r++;
- m[a[r]]++;
- m[a[l]]--;
- if(m[a[l]] == 0){
- m.erase(a[l]);
- }
- l++;
- }
- }
- RAW Paste Data
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- map<int, int>m;
- int n, k;
- cin>>n>>k;
- int a[n];
- for(int i = 0; i < n; i++){
- cin>>a[i];
- }
- for(int i = 0; i < k; i++){
- m[a[i]]++;
- }
- int l = 0, r = k - 1;
- while(r < n){
- cout<<m.begin()->first<<" ";
- r++;
- m[a[r]]++;
- m[a[l]]--;
- if(m[a[l]] == 0){
- m.erase(a[l]);
- }
- l++;
- }
- }
- Get link:https://ouo.io/xErMIY
Add Comment
Please, Sign In to add comment