Contest 1 - Hints to Problems [OFFICIAL]

Can anyone please explain me how to solve Multiple of 3 (Problem Code: MULTHREE).
I am getting the right answer only for first testcase given in the problem. For 2nd testcase I am getting wrong and 3rd testcase it takes too long for execution.
Please help.

where exactly??

I am getting garbage value for Laddu question. This is my code. Pls help!

#include <stdio.h>
#include <string.h>

int main(void) {
int T, acts, temp;
char nation, str[20];
char a[] = “CONTEST_WON”;
char b[] = “TOP_CONTRIBUTOR”;
char c[] = “BUG_FOUND”;

scanf("%d", &T);

while(T--) {
    int laddu=0;
    scanf("%d %c", &acts, &nation);
    for(int i=0; i<acts; i++) {
        scanf("%s", str);
        if(!strcmp(str, a)) {
            scanf("%d", &temp);
            laddu += 300+20-temp;

        else if(!strcmp(str, b))
            laddu += 300;
        else if(!strcmp(str, c)) {
            scanf("%d", &temp);
            laddu += temp;

        else laddu += 50;
    printf("%d ", laddu);
    if(nation == 'I') printf("%d\n", laddu/200);
    else printf("%d\n", laddu/400);
return 0;


Here’s my code for the problem with complexity O(1).
It’s still giving TLE by 0.01s.
I don’t think it can be optimized further :roll_eyes:.
Help me please.
Please have a look.

Okay,Brother you got right but check your solution for this case {2,3,4,5,97}, here the middle element is 4 but answer is 97, in this case you have to check for each element , You just have to need two array sort first one and solve one and put it in second array and sort them. You will Get the answer right. Hope you like it. :slight_smile:

for lapindromes you can sort first half and second half then compare…

using namespace std;
int main(){
int t;
for(int i = 0; i < t; i++){
unsigned long long int k;
int d0, d1;
int base = d0 + d1;
unsigned long long sum = 2 * (d0 + d1);
if(sum == 10){
int it = (k - 3)/4;
sum += (20 * it);
for(int m = 1; m <= ((k - 3) % 4); m++){
int x = (pow(2, m)*base);
sum += (x % 10);
if(sum % 3 == 0){
return 0;

This is my code for multiple of 3… Can someone tell me why it is showing WA