I am learning C++ and trying to solve this problem from Hackerearth link
I wrote a basic code for this on Dev-C++ 5.11 and due to some reason, it is not running.
There is no error in compiler, I tried printing things in main() function to see how much code it is executing, and it prints None!
I even tried executing an infinite loop on 1st line of main() but, code ends without doing anything. Here is my code:
#include <bits/stdc++.h>
using namespace std;
int main()
{
int N = 0;
cin >> N;
int m = N;
int x1=0, x2=0, y1=0, y2=0;
int c = 0;
int cost = 0, total_cost = 0;
int a[1000][1000] = {0};
while(m>0)
{
cin >> x1 >> x2 >> y1 >> y2 >> c;
cost = 0;
for(int i = y1; i<y2+1; i++)
{
for(int j = x1; j<x2+1; j++)
{
if(a[i][j] == 1)
{
cost++;
}
else
{
a[i][j] = 1;
}
}
}
total_cost += cost*c;
m--;
}
cout << total_cost;
}
I am new to C++, so any kind of help will be appreciated.