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