|
|
вернуться в форумC++ Well, this one turned out to be easy. Luckily there is a function in the header algorithm (stable_sort) that sorts the objects on the basis of one of its contents ! and that's all was needed here ! Re: C++ Try to think how to solve it without any sorting!!! Re: C++ without ANY sorting? How do you sort array without any sorting? Re: C++ It is not necessary to sort array :) Just read input + :) Re: C++ #include <cstdio> #include <algorithm> using namespace std; struct node { int id; int solve; } a [10000000 + 10]; bool cmp (node p, node q) { if ( p.solve > q.solve ) return true; return false; } int main () { int n; scanf ("%d", &n); for ( int i = 0; i < n; i++ ) scanf ("%d %d", &a [i].id, &a [i].solve); stable_sort (a, a + n, cmp); for ( int i = 0; i < n; i++ ) printf ("%d %d\n", a [i].id, a [i].solve); return 0; } |
|
|