Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main(){
- int g,l,maxx=0,now=-5; //maxx fih l position mta3 l frog lawel. now fih l frog lawel bch ken ma5lat 3lih 7ata 7ad nzidah +1 tour
- cin>>g>>l;
- map<int,int>mapp; // mapp hedhi feha kol frog wl position mta3ah
- map<int,int>score; // mapp hedhi feha kol frog w guedech mn tour fl sadara
- for(int i=1;i<=g;i++){
- mapp[i]=0;
- score[i]=0;
- } // mena 3amart l maps mta3i bl frogs
- for(int i=0;i<l-1;i++){
- int x,y;//x: frog num,,,, y: saut distance
- cin>>x>>y;
- mapp[x]+=y;
- if(mapp[x]==maxx) continue;
- else if(mapp[x]>maxx){
- score[x]++;
- maxx=mapp[x];
- now=x;
- }
- else if(now!=-5){
- score[now]++;
- }
- }
- int maxis=0; // maxis bch nchouf chkoun 3ndah akther score or chkoun 3ada akther atra7 lawel
- for(int i=1;i<=g;i++){
- maxis=max(score[i],maxis);
- }
- for(int i=1;i<=g;i++){
- if(score[i]==maxis){
- cout<<i;
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement