|
|
back to boardWrong Answer Posted by 1212346 27 Sep 2013 08:59 #include <stdio.h> #include <iostream> using namespace std; #define MAX 15000 struct Team { int ID; int M; }; void Swap(Team &A, Team &B) { Team temp = A; A = B; B = temp; } void QuickSort(Team A[], int left, int right) { int i, j; if (left >= right) return; int x = ((left + right)/2); i = left; j = right; while(i < j) { while (A[x].M < A[i].M) i++; while (A[j].M < A[x].M) j--; if(i <= j) { Swap(A[i], A[j]); i++; j--; } } QuickSort(A, left, j); QuickSort(A, i, right); } void main() { int N; Team A[MAX]; cin >> N; for (int i = 0; i < N; i++) cin >> A[i].ID >> A[i].M; QuickSort(A, 0, N - 1); for (int i = 0; i < N; i++) cout << A[i].ID << " " << A[i].M << endl; } |
|
|