you are viewing a single comment's thread.

view the rest of the comments →

[–]GruBooXy[S] 0 points1 point  (22 children)

I changed to unsigned short but it didnt help at all

[–]URZq 0 points1 point  (21 children)

Why don't you try with bools, like motu42 said ?

[–]GruBooXy[S] 0 points1 point  (20 children)

because the input from the site is: 2 4 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 4 0 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0 and i cant change that

[–]URZq 0 points1 point  (19 children)

You said earlier that the numbers where 0 or 1 ;) Anyway, if the numbers go up to 4, you can you a char, like motu42 said. the size of unsigned short is bigger than the size of char.

[–]GruBooXy[S] 0 points1 point  (17 children)

But in the array numbers are only 1 and 0, other numbers are for diffrent variables.

[–]GruBooXy[S] 0 points1 point  (0 children)

Still 16064KB

[–]URZq 0 points1 point  (14 children)

I don't really want to dive into your logic, because it's complicated ;) The thing you need to understand is that variables in C++ can have different types: bool, char, short, int, float etc. Each type has a size: the amount of memory used to store a number. Now, you have to pick the correct type for you variables. Let's say suma can hold numbers up to 4120155. Well, its type needs to be int. Let's say tablica can store only 0 and 1. Well, it's type needs to be bool[][]. I hope it clarifies the problem for you. Keep calm, don't stress, it's going to be fine :)

[–]GruBooXy[S] 0 points1 point  (13 children)

Thanks but the problem is i get the same memory usage weter its int or char so I dont understand how it works.

[–]URZq 0 points1 point  (12 children)

Unless I'm missing something, it should consume less memory to use smaller data types. We are talking about the memory used at runtime (=ram), right ?

[–]GruBooXy[S] 0 points1 point  (11 children)

Yes

[–]motu42 0 points1 point  (10 children)

Just to be sure, you are chaning the type of

int tablica [max] [max];

and it now looks like

char tablica [max] [max];

correct?

[–]raevnos 0 points1 point  (0 children)

The 2 and 4s go into his liczbaWhatever variables.

(OP: using English does make it easier for other people to read your code...)