Advertisement
Guest User

Untitled

a guest
Feb 25th, 2020
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <map>
  4. #include <algorithm>
  5. #define pb push_back
  6. using namespace std;
  7. int main(){
  8. ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  9. int n;
  10. cin >> n;
  11. vector<int> m;
  12. m.reserve(n);
  13. for(int i = 0; i < n; i ++){
  14. int inp;
  15. cin >> inp;
  16. m.pb(inp);
  17. }
  18. map<int,int> cnt;
  19. for(int i = 0; i < n; i ++){
  20. if(cnt.count(m[i]) == 0){
  21. cnt[m[i]] = 1;
  22. }
  23. else{
  24. cnt[m[i]] += 1;
  25. }
  26. }
  27. map<int,int> first;
  28. map<int,int> last;
  29. vector<int> ind;
  30. for(int i = n-1; i > -1; i --){
  31. if(first.count(m[i]) == 0){
  32. first[m[i]] = i;
  33. ind.pb(m[i]);
  34. }
  35. }
  36. for(int i = n-1; i > -1; i --){
  37. if(last.count(m[i]) == 0){
  38. last[m[i]] = i;
  39. }
  40. }
  41. sort(ind.begin(),ind.end());
  42. vector<vector<int>> dp;
  43. if (first[ind[0]] == last[ind[0]]){
  44. dp.pb({1+first[ind[0]],99999999});
  45. }
  46. else{
  47. dp.pb({99999999,last[ind[0]]+cnt[ind[0]]})
  48. }
  49. for(int i = 1; i < ind.size()); i++){
  50. if(first[ind[i]] == last[ind[i]]){
  51.  
  52. }
  53.  
  54.  
  55. }
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement