Untitled
unknown
plain_text
2 years ago
583 B
2
Indexable
Never
#include <fstream> using namespace std; struct uniforma { int cod, nrE; }; uniforma u[12]; int main() { ifstream cin("serbare.in"); ofstream cout("serbare.out"); int n, p, elevi, codul; cin>>n>>p; for(int i=1; i<=n; i++) { cin>>elevi>>codul; u[codul].cod=codul; u[codul].nrE+=elevi; } for(int i=1; i<=n; i++) { for(int j=i+1; j<=n; j++) { if(u[i].nrE<u[j].nrE) { swap(u[i], u[j]); } } } for(int i=1; i<=p; i++) { cout<<u[i].cod<<" "; } return 0; }