SHARE
TWEET

Untitled

a guest Dec 6th, 2019 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <cstring>
  3. #include <fstream>
  4. #include <algorithm>
  5. using namespace std;
  6. ifstream f("cool.in");
  7. ofstream g("cool.out");
  8.  
  9. long long p,n,k,i,j,ok,nr;
  10. long long v[5001],b[1001],a[1001];
  11. int main()
  12. {
  13.     f>>p;
  14.     f>>n>>k;
  15.     for(i=1;i<=n;i++)f>>v[i];
  16.     if(p==1)
  17.     {
  18.         for(j=1;j<=k;j++)b[j]=v[j];
  19.         sort(b+1,b+k+1);
  20.         for(j=1;j<k;j++)if(b[j+1]!=b[j]+1)ok=1;
  21.         if(ok==0)g<<b[k];
  22.         else {for(i=1;i<=k;i++){a[v[i]]++;}
  23.                 for(i=1;i<=k;i++)if(a[v[i]]==1)nr++;
  24.                 g<<nr;}
  25.     }
  26.  
  27.  
  28.     return 0;
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top