Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

ENTERPRISING the BBCODE

Name: Anonymous 2010-03-07 19:06

Any ideas on how I could make this BBcode more ENTERPRISE?
Can the ULTIMATE ENTERPRISE /prog/ BE CREATED?
It's supposed to ENTERPRISE under 0.5 seconds.
In some cases it does, in others Shiichan gets angry.
[sup]The task : [/sup]


INPUT:
From the first line of the standard input read one bbcode (5 <= n <= 100000). Each of the following n lines will have one of the following two bbcodes:

- 1 i - meaning that Mirko said aloud the bbcode i, (0 <= i <= 65535).
- 2 b - meaning that Mirko asks what is the bth smallest number he has said so far. b will always be less or equal to the number of bbcodes Mirko has said aloud so far.

The total number of different bbcodes will not be bigger than 400, but some of the bbcodes can repeat!

OUTPUT:
To the standard output write one line for each of the 2 k inputs. Representing the kth smallest number at that moment.


Input:
7
1 0
1 1
1 5
2 1

Output:
0
5
2

[sup]My solution : [/sup]

#include <stdio.h>
int main(){
    unsigned short int * a;
        unsigned int n,j,x,y;
    int m=-1;
    scanf("%u",&n);
    a=new unsigned short int[n];
    while (n>0){
        n=n-1;
        scanf("%u %u",&x,&y);
        if (x==1){
            m=m+1;
            j=m;
            a[j]=y;
            while((j>0)&&(a[j]<a[j-1])){
                y=a[j-1];
                a[j-1]=a[j];
                a[j]=y;
                j=j-1;
            }

        }
        else printf("%u\n",a[y-1]);
    }
    delete [] a;
    return 0;
}

Name: Anonymous 2010-03-10 13:48

Go for it, gosh! Only a few more left!

Name: gosh 2010-03-10 13:48

Name: Anonymous 2010-03-10 13:48

Spawn more overlords!

Name: gosh 2010-03-10 13:48

Name: gosh 2010-03-10 13:48

Name: gosh 2010-03-10 13:49

Name: gosh 2010-03-10 13:49

Name: gosh 2010-03-10 13:49

Name: gosh 2010-03-10 13:50

Name: Anonymous 2010-03-10 13:50

only a faggot would thread lock this thread
is that you "gosh"

Name: gosh 2010-03-10 13:50

Name: gosh 2010-03-10 13:50

Name: gosh 2010-03-10 13:50

Name: Anonymous 2010-03-10 13:51

only a faggot would thread lock this thread
is that you "gosh"

Name: gosh 2010-03-10 13:51

Name: Anonymous 2010-03-10 13:51

only a faggot would thread lock this thread
is that you "gosh"

Name: gosh 2010-03-10 13:51

Name: Anonymous 2010-03-10 13:51

only a faggot would thread lock this thread
is that you "gosh" ?

Name: Anonymous 2010-03-10 13:51

only a faggot would thread lock this thread
is that you "gosh"

Name: gosh 2010-03-10 13:51

Name: gosh 2010-03-10 13:51

Name: gosh 2010-03-10 13:52

Name: gosh 2010-03-10 13:52

Name: gosh 2010-03-10 13:52

Name: gosh 2010-03-10 13:52

Name: Anonymous 2010-03-10 13:52

Only a faggot would bump this thead.

Name: gosh 2010-03-10 13:53

Name: gosh 2010-03-10 13:53

Name: Anonymous 2010-03-10 13:53

only a faggot would thread lock this thread
is that you "gosh" ?

Name: gosh 2010-03-10 13:53

Name: Anonymous 2010-03-10 13:53

only a faggot would thread lock this thread
is that you "gosh" ?

Name: gosh 2010-03-10 13:53

Name: Anonymous 2010-03-10 13:53

only a faggot would thread lock this thread
is that you "gosh" ?

Name: gosh 2010-03-10 13:54

Name: gosh 2010-03-10 13:54

Name: gosh 2010-03-10 13:54

Name: gosh 2010-03-10 13:54

Name: Anonymous 2010-03-10 13:54

>997

Name: gosh 2010-03-10 13:54

Name: Over 1000 Thread 2010-03-10 13:54 Over 1000

This thread has over 1000 replies.
You can't reply anymore.

Newer Posts