Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя codepasta

Автор codepasta, 4 года назад, По-английски

helloo, codeforce!!!11!

problem statement is: given a and b, print a + b. a and b <= 1000000000

why is this problem giving ''time limit exceedded''?????

here is my submisssion:

#include <iostream>

using namespace std;

int main()

{

int a, b;

int i;

int answerr = 0;

cin >> a;

cin >> b; for (i = 1; i<=a; i = i + 1) answerr = answerr + 1; for (i = 1; i<=b; i = i + 1) answerr = answerr + 1; cout << answerr; return 0; }

pleasse helppp, thank you!!111!!

  • Проголосовать: нравится
  • -51
  • Проголосовать: не нравится

»
4 года назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

After seeing this post, I got a feeling why codeforces didn't have the report option.

»
4 года назад, # |
  Проголосовать: нравится +4 Проголосовать: не нравится

That is a lie. It shouldn't get TLE. The reason for that is compiler optimizations. And as you declared a,b,i as integers not volatile integers, so it shouldn't timeout as compiler optimizes the loop to O(1) only. Now, stop lying greendian.

  • »
    »
    4 года назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    That's a strong assumption to make given that we don't know what compiler he is using and whether optimisation is turned on or not.

»
4 года назад, # |
  Проголосовать: нравится +5 Проголосовать: не нравится

Smh. Fake news. It gets an AC in 0.00s.
Proof

»
4 года назад, # |
Rev. 4   Проголосовать: нравится +26 Проголосовать: не нравится

Elo Sir. I sir had same issue. plz help???

include <bits/stdc++.h>

using namespace std;

define ll long long int

define SLOWIO sync_with_stdio(true); cout.tie(cin); cout.tie(cerr); cin.tie(cout); cin.tie(cerr); cerr.tie(cout); cerr.tie(cin);

int main() { SLOWIO ll a, b; cin >> a >> b; cout << "Is it rated?" << endl; return 0; }

may codeforce be with us!!!1!!111!