Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
AC codeSource 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator