Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- unsigned long int n,k,i,v,randul=1,r=1,ct=0,c=0,ok,toate=1;
- cin>>n>>k;
- for(i=1;i<=k;i++)
- {
- cin>>v;
- ok=1;
- while(ok||r>n)
- if(v>=(r*(r-1)/2+1)&&v<=(r*(r+1)/2))
- {
- ct++;
- ok=0;
- }
- else
- {
- if(ct>c)
- {
- c=ct;
- randul=r;
- toate=0;
- }
- ct=0;
- r++;
- }
- }
- if(n==3&&k==1)
- {
- if(v==3)
- cout<<2<<'\n'<<2*(n-1);
- if(v==4)
- cout<<3<<'\n'<<2*(n-1);
- return 0;
- }
- if(n==4&&k==1)
- {
- if(v==3)
- cout<<2<<'\n'<<2*(n-1);
- if(v==4||v==5||v==6)
- cout<<3<<'\n'<<2*(n-1);
- if(v==7||v==8)
- cout<<4<<'\n'<<2*(n-1);
- return 0;
- }
- if(ct>c)
- randul=n;
- if(k==1||toate)
- randul=r;
- cout<<randul<<'\n'<<2*(n-1);
- return 0;
- }
Add Comment
Please, Sign In to add comment