When i run this program at dev cpp, task manager says that it's about 79 MB. Codeforces with gnu c++ 4.7 says that it's 79112 kilobytes
#include<stdio.h>
const int N=10010,K=1010;
struct TPos
{
int charge;
bool ex;
TPos()
{
charge=1<<30;
ex=false;
}
};
TPos d[N][K];
int main()
{
while(1);
return 0;
}
But when ex parametr is commented:
#include<stdio.h>
const int N=10010,K=1010;
struct TPos
{
int charge;
//bool ex;
TPos()
{
charge=1<<30;
//ex=false;
}
};
TPos d[N][K];
int main()
{
//while(1);
return 0;
}
it's only 39536 KB. I thought that boolean should use one byte. Why does it double the size?
sizeof(int)
if you do not need all int-bits forcharge
. See my answer below. (Maybe one more or less power of 2 in charge does not make a big difference.)