Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream fin("serbare.in");
- ofstream fout("serbare.out");
- struct uniforma
- { int tip;
- int nr;
- };
- uniforma u[12], aux;
- int main()
- { int n, p,x,y;
- fin>>n>>p;
- for(int i=1; i<=n; i++)
- {fin>>x>>y;
- u[y].nr=u[y].nr+x;
- u[y].tip=y;}
- fin.close();
- for(int i=1; i<=p; i++)
- for(int j=i+1; j<=p; j++)
- if(u[i].nr<u[j].nr)
- {aux=u[i];
- u[i]=u[j];
- u[j]=aux;}
- for(int i=1; i<=p; i++)
- fout<<u[i].tip<<" ";
- fout.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement