Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int v[100001];
- int main()
- {
- int i, maj, ap, n;
- cin>>n;
- cin>>v[1];
- maj=v[1];
- ap=1;
- for(i=2; i<=n; i++)
- {
- cin>>v[i];
- if(v[i]==maj)
- {
- ap++;
- }
- else
- {
- ap--;
- if(ap==0)
- {
- ap=1;
- maj=v[i];
- }
- }
- }
- ap=0;
- for(i=1; i<=n; i++)
- {
- if(v[i]==maj)
- {
- ap++;
- }
- }
- if(ap>n/2)
- {
- cout<<"DA"<<' '<<maj;
- }
- else
- {
- cout<<"NU";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment