ppastram's blog

By ppastram, history, 4 years ago, In English

Hi everyone. I'm getting the right answer on the first couple of test cases on a fairly easy problem but on the third one I get "time limit exceeded". Here's my submission: https://codeforces.com/contest/1325/submission/82660385 . If anybody can think of a way to make my solution more efficient it would help a lot!

Thank you very much.

Full text and comments »

  • Vote: I like it
  • +6
  • Vote: I do not like it

By ppastram, history, 4 years ago, In English

Hi everyone, I'm solving problem A from round #575 (div 3). It's a fairly simple problem and I'm getting the right answer when I try the example on visual studio code (using c++) but when I upload my solution, I get the third case wrong (the one with big numbers). Why can this happen?

Useful info: problem: https://codeforces.com/contest/1196/problem/A my code:

include

int main() { int n = 0; std::cin >> n;

for (int i = 0; i < n; i++)
{
    long total = 0;
    long a = 0;
    long b = 0;
    long c = 0;
    std::cin >> a;
    std::cin >> b;
    std::cin >> c;
    total = a+b+c;
    if (int(total)%2==0)
        std::cout<<total/2 <<"\n";
    else
        std::cout<<(total-1)/2 <<"\n";

}
return 0;

}

example entry: 4 1 3 4 1 10 100 10000000000000000 10000000000000000 10000000000000000 23 34 45 my output on vs code (right answer): 4 55 15000000000000000 51 my output when I submit my solution: 4 55 1073741823 0

Thank you very much for your help!

Full text and comments »

  • Vote: I like it
  • -5
  • Vote: I do not like it