I'm having trouble compiling code with a struct vector. The compiler keeps sending errors, but I cannot locate any. The code is right beneath.
//2018 USACO Bronze Task 2
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
struct Period{
int end,starting;
};
int main(){
ifstream fin("lifeguards.in");
ofstream fout("lifeguards.out");
int N;
fin>>N;
vector <Period> periods[N];
for(int i=0;i<N;i++){
fin>>periods[i].starting>>periods[i].end;
}
int record=0,temp=0;
for(int i=0;i<N-1;i++){
temp+=periods[i].end-periods[i].starting;
for(int j=0;j<N;j++){
if(j==i)continue;
temp+=periods[j].end-periods[j].starting;
temp-=max(periods[i].end-periods[j].starting,0);
}
if(temp>record)record=temp;
temp=0;
}
fout<<record<<endl;
}
The error message is in the link Errmsg I have checked for any possible grammatical errors that I know of, but it keeps popping out compilation errors. Is there any fix to this?