|
|
back to board4 lamers -> AC <- :) (C++ rulezzzz) #include <stdio.h> #include <math.h> #include <stdlib.h> int n, k, a[100001], nr; char s[4]; int cmp (const void * a, const void * b) { return ( *(int*)a - *(int*)b ); } int main() { #ifndef ONLINE_JUDGE freopen("1026.in", "r", stdin); freopen("1026.out", "w", stdout); #endif long i = 0; scanf("%ld", &n); for (i = 1; i <= n; ++i) { scanf("%ld", &a[i - 1]); } scanf("%s", s); scanf("%ld", &k); qsort(a, n, sizeof(int), cmp); for (i = 1; i <= k; ++i) { scanf("%ld", &nr); printf("%ld\n", a[nr - 1]); } return 0; } good luck! =)) Re: 4 lamers -> AC <- :) (C++ rulezzzz) This isn't beatiful sol)) There is rather cooler one)) Re: 4 lamers -> AC <- :) (C++ rulezzzz) It's very easy problem.Don't post solutions here,please! Edited by author 20.11.2007 00:08 Re: 4 lamers -> AC <- :) (C++ rulezzzz) Posted by svr 20 Nov 2007 00:19 Why not? We can see individual stile and elegance, some desisions very bright, it's mastering C++ frequently. But now more profitable algo- technology and effectiveness than art of C . Frequently authoths of bright solution can't manage mathematical adequate algos. Try to solve challenge team problems as criterion. Edited by author 20.11.2007 00:26 Re: 4 lamers -> AC <- :) (C++ rulezzzz) #include <stdio.h> #include <stdlib.h> .. int cmp (const void * a, const void * b) { return ( *(int*)a - *(int*)b ); } int main() { ... qsort(a, n, sizeof(int), cmp); #include <algorithm> using namespace std; int main() { ... sort(ar, ar + n); ... } good luck ) Re: 4 lamers -> AC <- :) (C++ rulezzzz) this is a wrong solution.u dont need to sort at all. Re: 4 lamers -> AC <- :) (C++ rulezzzz) Why don't? I think you only need to choose the right sort algo) |
|
|