|
|
вернуться в форумTLE I'm getting time limit exceeded using this algorithm, any optimization suggestions? This problem is taking almost a week 8-| total = 0 for i from 1 to N for j from 0 to M total++ print total Edited by author 07.06.2015 11:34 Re: TLE why using loop, just simply, we have N element array. And we have (M+1) integers, as numaration starts form 0 to M. so, (M+1) integers will be checked in every element of the array. as, there's N elements in the array, so, final result is N*(M+1). :) ------------------------------------ #include <iostream> using namespace std; int main() { int n, m;
cin >> n >> m; cout << n * (m + 1) << '\n'; return 0; } --------------------------------------- Edited by author 08.06.2015 22:43 |
|
|