POJ 3320 ft., Hash,map Mark

Source: Internet
Author: User

1, POJ 3320

2, Link: http://poj.org/problem?id=3320

3, Summary: ruler, Hash,map Mark

Reading review, p page book, a page has a knowledge point, continuous look at the minimum number of pages to read all the knowledge points

Must say, STL enough Dick.

#include <iostream>#include<cstring>#include<cmath>#include<queue>#include<algorithm>#include<cstdio>#include<map>using namespacestd;#defineLL Long Long#defineINF 0x3f3f3f3fConst intn=1000100;intP,a[n];map<int,int>n,x;intMain () { while(~SCANF ("%d",&p)) { for(intI=1; i<=p;i++) {scanf ("%d",&A[i]); N[a[i]]++; }        intS=n.size ();//total category of records        intL=1, r=1, ans=INF;  while(true)        {             while((r<=p) && (X.size () <s)) {//to meet the range requirements, otherwise the right endpoint movesx[a[r++]]++; }            if(X.size () <s) Break; Ans=min (ans,r-l); X[a[l++]]--; if(x[a[l-1]]<=0) X.erase (a[l-1]);//key point, within the range of this category number <=0, delete} printf ("%d\n", ans); }    return 0;}
View Code

POJ 3320 ft., Hash,map Mark

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.