I got TLE with this code but when I tried n=10000 it work faster than 3s.
Please help me improve my code.
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
int sum,n[10005],tmp[10005],big;
while(1)
{
scanf("%d",&sum);
if(sum==0)
break;
for(int i=0;i<sum;i++)
{
scanf ...
Search found 4 matches
- Thu Sep 26, 2013 5:14 pm
- Forum: Volume 106 (10600-10699)
- Topic: 10684 - The jackpot
- Replies: 34
- Views: 25216
- Wed Apr 24, 2013 3:36 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10055 - Hashmat the Brave Warrior
- Replies: 166
- Views: 77266
Re: 10055 - Hashmat the Brave Warrior
It works! thanks a lot
btw if i want to read only 1 input until the end of input, does the code look like this?
while(scanf("%lld",&e) == 1) {

btw if i want to read only 1 input until the end of input, does the code look like this?
while(scanf("%lld",&e) == 1) {
- Tue Apr 23, 2013 4:41 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10055 - Hashmat the Brave Warrior
- Replies: 166
- Views: 77266
Re: 10055 - Hashmat the Brave Warrior
what this line do?
while(scanf("%lld %lld",&h,&e) == 2) {
i'm sorry, i'm new with this thing.
while(scanf("%lld %lld",&h,&e) == 2) {
i'm sorry, i'm new with this thing.
- Sun Apr 21, 2013 8:25 pm
- Forum: Volume 100 (10000-10099)
- Topic: 10055 - Hashmat the Brave Warrior
- Replies: 166
- Views: 77266
Re: 10055 - Hashmat the Brave Warrior
what's wrong with my code? i got WA with this
Code: Select all
#include<stdio.h>
int main()
{
long long int h,e;
while(!EOF)
{
scanf("%lld %lld",&h,&e);
if(h<e)
printf("%lld\n",e-h);
else
printf("%lld\n",h-e);
}
return 0;
}