I ran these codes in custom invocation and got weird running times.
#include<bits/stdc++.h>
using namespace std;
int main(){
//Hi
for(int i=0;i<5000000;i++)cout<<i<<" ";
return 0;
}
Run time: 2448 ms
#include<bits/stdc++.h>
using namespace std;
int main(){
for(int i=0;i<5000000;i++)cout<<i<<" ";
return 0;
}
Run time: 2901 ms
Can anyone explain why adding comment is having significant impact on running times?
PS: Changing comment affected run time slightly as well.
I guess it should just be difference between each runs. And codeforces caches your submission so if you submit one multiple times, it will return the same result.
"I guess it should just be difference between each runs." I didn't get you. Can you please rephrase the statement?
Due to dynamic CPU frequency, server load or some other reasons, time required for processing the same data by identical program may varies. As a result, several runs of a program may result different time consumed.
Sorry for my bad English, hope this makes more sense.
As Laakeri has mentioned, the difference is quite high (450 ms).
This extent of difference is possible, at least on my machine (the result of running OP's program):
So I can get AC/TLE with same code depending upon server status? That's not really good. :/
Online judge should not be so unstable that time difference between runs of the same program is over 400 ms.
Tried it 8 times. If I change the comment for "Petr" it works.
CodeForces doesn't recompile your code if it's the same (at least in some time window)
so tried 8 times may mean that result just was cached
Took that into account. I tried it on different windows and making changes on the code.