The code below is showing two errors. They are the one belows: C4552 '>>' operator has no effect; expected operator with side-effect expression must have constant value; expected operator with side-effect (related to the variable 'size'
The code is the one below:
#include <iostream>
#include <fstream>
#include <algorithm>
using namespace std;
int main()
{
int size;
cin >> size;
int lectures[size][2];
for (int i = 0; i < size; i++) {
cin >> lectures[i][0] >> lectures[i][1];
}
int n = sizeof(lectures) / sizeof(lectures[0]);
int prefix_sum[size] = { 0 };
for (int i = 0; i < n; i++) {
prefix_sum[lectures[i][0]]++;
prefix_sum[lectures[i][1] + 1]--;
}
int ans = prefix_sum[0];
for (int i = 1; i < size; i++) {
prefix_sum[i] += prefix_sum[i - 1];
ans = ans < prefix_sum[i] ? prefix_sum[i] : ans;
}
cout << ans;
return 0;
}
Can someone please help me to understand what is wrong here? Any help is welcome! Thank you! :)