Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:大水题

Posted by 20171344133 at 2018-05-18 18:28:50 on Problem 3320
In Reply To:大水题 Posted by:13408100238 at 2015-03-29 19:57:12
> #include <iostream>
> #include <cstdio>
> #include <cstring>
> #include <cmath>
> #include <algorithm>
> #include <string>
> #include <vector>
> #include <set>
> #include <map>
> #include <queue>
> #include <stack>
> #include <sstream>
> #include <iomanip>
> using namespace std;
> const int INF=0x4fffffff;
> const int EXP=1e-6;
> const int MS=1000005;
> 
> int page[MS];
> set<int> s;
> map<int,int> mp;
> int n;
> 
> void solve()
> {
>       int cnt=s.size();
>       int ans=n;
>       int num=0;
>       int s=0,t=0;
>       while(1)
>       {
>             while(t<n&&num<cnt)
>             {
>                   if(mp[page[t++]]++==0)
>                         num++;
>             }
>             if(num<cnt)
>                   break;
>             ans=min(ans,t-s);
>             if(--mp[page[s++]]==0)
>                   num--;
>       }
>       printf("%d\n",ans);
> }
> 
> int main()
> {
>       scanf("%d",&n);
>       for(int i=0;i<n;i++)
>       {
>             scanf("%d",&page[i]);
>             s.insert(page[i]);
>       }
>       solve();
>       return 0;
> }
> 
> 

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator