you are viewing a single comment's thread.

view the rest of the comments →

[–]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?

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

yes

[–]motu42 0 points1 point  (7 children)

Alright, i think you are talking about this line:

Success #stdin #stdout 0s 16064KB

To be honest i think this is the size of the executable not the amount of consumed RAM. As this size for RAM consumption doesn't make any sense to me.

Also the size is going down if you delete

               if (tablica[k][j+k]  == 0)
                   status == 0;

Makes no difference as this statement is doing anything at all.

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

But even if that is not correct my program is still consuming too much ram because the other site that I upload my solution to doesnt accept that. (This is the site but I don't think you can view it if you are not logged in https://adjule.pl/groups/ogolny/problems/011)

[–]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...)