Time Limit Exceed

Hi!
I am getting time limit exceed in USACO Milking Cow question.
My code is below.

#include
using namespace std;

int main(){
    ifstream fin("milk2.in");
    ofstream fout("milk2.out");
    int n;
    fin >> n;
    long long time[n][2],maxspend=0,mingain=0,truemax=0,maxgain=0;
    for(int i=0;i> time[i][0] >> time[i][1];
    for(int i=0;i<n-1;i++)
        maxspend = max(maxspend,time[i+1][0]-time[i][1]);
    for(int i=0;i= time[i+1][0]){
        mingain = time[i][0];
        for(int j=i;= time[i+1][0]);j++){
            maxgain = max(maxgain,time[i+1][1]);
        }
        }
        truemax = max(truemax,maxgain-mingain);
    }
    fout << truemax << " " << maxspend << endl;
    return 0;
}

Can anyone explain me why I am getting TLE.
Thank’s

//