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

AC code

Posted by caizixian at 2010-02-09 14:19:54 on Problem 1989
Source Code
Problem: 1989		User: caizixian
Memory: 352K		Time: 250MS
Language: C++		Result: Accepted

    * Source Code

      #include<iostream>
      #include<memory>
      using namespace std;
      int main()
      {
      bool flag[100005];
      memset(flag,0,100005);
      int n,k;
      cin>>n>>k;
      int count = 0;
      int sum = 1;
      while(n--)
      {
         int temp;
         scanf("%d",&temp);
         if(flag[temp] == false)
         {
          count ++;
          flag[temp] = true;
          if(count == k)
          {
           sum++;
           count = 0;
           memset(flag,0,sizeof(flag));
          }
         }
      }
      cout<<sum<<endl;
      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