CKS005 - Editorial

Vyuh Rachna

Author: artha6391

Tester: anushka_nagar

Editorialist: atharv_110

DIFFICULTY:

EASY

PREREQUISITES:

BASIC MATH

PROBLEM:

We have N 6-sided standard dice. Each die has dimensions 1×1×1.

First, we form four vertical stacks of dice, which together make up a pile of dice with a base area up to 2×2. Among all such structures, the total visible surface area of this structure must be the smallest possible.

Then, we calculate the number of pips on the visible faces of all dice in the structure. Among all possible arrangements of dice, what is the maximum possible total number of visible pips?

QUICK EXPLANATION:

For minimum visible area, dice should be stacked together, 4 dice in a level.

If 4 is not possible then arranged as such they share a face to minimize the visible surface area.

Each dice must be kept in such a way that the faces with more pips are visible.

EXPLANATION:

For minimum visible area, dice should be stacked together, 4 dice in a level.

Only at the topmost level, it can be \leq 4 dice, or only if N \leq 4.

In other words, if there are N dice then floor (N/4) levels would be there with 4 dice at each level.

if N mod 4 != 0, then there would be a level with \leq 4 (i.e. N mod 4) dice.

In the top tier, the dice should be arranged as such they share a face with each other for minimizing the visible surface area.

For any dice,

If 5 faces are visible, then the values should be 6, 5, 4, 3, 2.

if 4 faces are visible, then the values should be 6, 5, 4, 3.

if 3 faces are visible, then the values should be 6, 5, 4.

if 2 faces are visible, then the values should be 6, 5.

For example,

If N = 4, then the number of visible faces in each dice is 3. So, the total number of pips in the structure would be 4*(6+5+4), which is equal to 60.

SOLUTIONS:

Setter’s Solution

#include<bits/stdc++.h>

using namespace std;

#define ll long long int

int main()

{

int i,j,k,t;

cin>>t;

while(t–){

ll n;

cin>>n;

ll ans=0;

if(n%4==1){

ans=20;

}

if(n%4==2){

ans=36;

}

if(n%4==3){

ans=51;

}

ll times=n/4LL;

ans+=times*44LL;

if(times>=1){

ans+=(4LL*(ll)(4-n%4));

}

cout<<ans<<“\n”;

}

return 0;

}

Tester’s Solution

#include<bits/stdc++.h>

using namespace std;

#define ll long long int

int main()

{

int i,j,k,t;

cin>>t;

while(t–){

ll n;

cin>>n;

ll ans=0;

if(n%4==1){

ans=20;

}

if(n%4==2){

ans=36;

}

if(n%4==3){

ans=51;

}

ll times=n/4LL;

ans+=times*44LL;

if(times>=1){

ans+=(4LL*(ll)(4-n%4));

}

cout<<ans<<“\n”;

}

return 0;

}

Editorialist’s Solution

#include<bits/stdc++.h>

using namespace std;

#define ll long long int

int main()

{

int i,j,k,t;

cin>>t;

while(t–){

ll n;

cin>>n;

ll ans=0;

if(n%4==1){

ans=20;

}

if(n%4==2){

ans=36;

}

if(n%4==3){

ans=51;

}

ll times=n/4LL;

ans+=times*44LL;

if(times>=1){

ans+=(4LL*(ll)(4-n%4));

}

cout<<ans<<“\n”;

}

return 0;

}