|
|
вернуться в форум1100 Final Standings Solved Using C++ STL Vector , Pair And stable_sort Here is my Solution. As this problem is related to stable sort and there is built in stable_sort function in c++ so it has become easier #include <bits/stdc++.h> using namespace std; bool compare( const pair<long long int,long long int>& x, const pair<long long int, long long int>& y ) { return (x.second>y.second); } int main() { vector<pair<long long int,long long int> >a; long long int n,i,j,b,c; cin>>n; for(i=1;i<=n;i++) { cin>>b>>c; a.push_back(pair<long long int,long long int>(b,c)); } stable_sort(a.begin(),a.end(),compare); //must include stable_sort vector<pair<long long int,long long int> >::iterator p; for(p=a.begin();p!=a.end();p++) { cout<<p->first<<" "<<p->second<<endl; } return 0; } Edited by author 11.06.2016 01:55 |
|
|