ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1026. Questions and Answers

4 lamers -> AC <- :) (C++ rulezzzz)
Posted by alexutz_mircescu 19 Nov 2007 19:19
#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)
Posted by AlexF [USTU Frogs] 19 Nov 2007 22:26
This isn't beatiful sol)) There is rather cooler one))
Re: 4 lamers -> AC <- :) (C++ rulezzzz)
Posted by CHIDEMYAN SERGEY 20 Nov 2007 00:06
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)
Posted by Alias (Alexander Prudaev) 20 Nov 2007 09:53
alexutz_mircescu wrote 19 November 2007 19:19
#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)
Posted by AlexF [USTU Frogs] 11 Dec 2007 16:23
Why don't? I think you only need to choose the right sort algo)