views:

213

answers:

1
#include<iostream>

using namespace std;

int main()
{
    int hash, opp, i, j, c = 0;

    //cout<<"enter hasmat army number and opponent number\n";
    while(cin>>hash>>opp)
    {
        cout<<opp-hash<<endl;
    }
}

time limit for this problem: 3.000 seconds how can i verify and test this condition?

i'm submitting this to a computer online, how exactly can i know run time error? should i calculate run time and memory?

explain me how to check runtime and memory in c++ in linux, i'm using gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu9).

+1  A: 

Once you've compiled your program, check its running time by running it with the Unix program time:

time ./myprogram

This will print how much "real" (human) time was taken, and how much CPU (active processing) time.

If you want to check how much memory your program uses, run it in the debugger and set a breakpoint where you want to inspect the memory usage, or just put a long sleep() in your code and run it without the debugger. Then you can use tools like ps or top to see how much memory (virtual, resident, etc.) is in use by your program.

John Zwinck