I need a very long variable c++

  c++, integer, long-integer, unsigned, variables

I tried to solve this probleme from codeforce https://codeforces.com/contest/363/problem/B
but in test 7 it show me this message : Time limit exceeded on test 7 I don’t know why i tried to replace int with long long but it didn’t work this is my code:

#include <iostream>
using namespace std;

int main()
{
     long long n;
     long long k;
    cin>>n>>k;
     long long a[n];
    for( long long i=0; i<n; i++){
        cin>>a[i];
    }
     long long psum=1000000;
     long long st=0;
     long long sum=0;
    for( long long i=0; i<n-k+1; i++){
        for( long long j=0; j<k; j++){
            sum+=a[i+j];
        }
        if(sum<psum){
            st=i+1;
        }
        psum=sum;
        sum=0;
    }
    cout<<st;
    
    return 0;
}

Source: Windows Questions C++

LEAVE A COMMENT