You are not logged in. Please login at www.codechef.com to post your questions!

×

about CAMPON problem of December Cook-Off 2018 Division 2

Hey I am getting successfully executed for the "CAMPON" problem in online compiler of codechef. But when I am trying to submit the code, at that time it is giving Wrong Answer. But my answer is correct. Please help me..........

Here is my Code for CAMPON problem of December Cook-Off 2018 Division 2:

include<iostream>

using namespace std;

int T, D, Q;

bool camp_or_not(int d, int p, int dead, int req){ int sum = 0; bool res = false;

for(int i=0;i<D;i++){
    if(dead > d[i]){
        sum += p[i];
        if(sum >= req) return true;
    }
}
return false;

} int main(){

//int T, D, Q;
cin>>T;
while(T--){
    cin>>D;
    int d[D], p[D];
    for(int i=0;i<D;i++){
        cin>>d[i]>>p[i];
    }
    cin>>Q;
    int dead[Q], req[Q];
    for(int i=0;i<Q;i++){
        cin>>dead[i]>>req[i];
        int res = camp_or_not(d, p, dead[i], req[i]);
        if(res) cout<<"Go Camp\n";
        else cout<<"Go Sleep\n";
    }


}

return 0;

}

asked 24 Dec '18, 11:25

ashishnar_123's gravatar image

1★ashishnar_123
1
accept rate: 0%


Hey, The thing is that you have tested your program only on the given sample cases and there are many other hidden cases for which your program wasn't able to give the right answer and hence your code is giving you verdict as WA. Try your code on some more sample cases and try to debug your code and then resubmit your code.

link

answered 24 Dec '18, 12:02

akash19jain's gravatar image

3★akash19jain
1377
accept rate: 10%

actually when I am running this code on online compiler of codechef then it is getting accepted but it shows WA while submitting. so on online compiler all the test cases getting pass.

(24 Dec '18, 16:16) ashishnar_1231★

The online compiler of codechef is like any other ide. When you run your code on the compiler, it runs your code on the test cases which need to be entered by you manually. And hence your code has some mistakes which you need to spot and then enter the test cases manually.

(24 Dec '18, 21:01) akash19jain3★

Here's your solution which passes all the test cases with some minor modifications made by me. I'd encourage you to spot the mistakes by yourself or if you are stuck, look at your AC solution for hints.

https://www.codechef.com/viewsolution/22075184

link

answered 24 Dec '18, 17:29

masood786's gravatar image

4★masood786
1063
accept rate: 13%

@ashishnar_123 i think you should do like this if(dead>=d[i).....

link

answered 24 Dec '18, 22:02

pshrimal000's gravatar image

2★pshrimal000
1
accept rate: 0%

I am facing same issue, I am new to codecheff, so m not really familiar with how testing here works. But I feel pretty sure about my code, any help would be appreciated.

#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ull unsigned long long


int main()
{
    SPEED;
    int t;
    cin>>t;
    while(t--)
    {
        int n, d ,p, q, d1, p1, prev = 0;
        cin>>n;
        vector<int> ded;
        int probs[n];
        for(int i = 0; i < n; i++)
        {
                cin>>d>>p;
                ded.push_back(d);
                probs[i] = p + prev;
                prev = probs[i];
        }
        cin>>q;
        while(q--)
        {
            cin>>d1>>p1;
            int index = lower_bound(ded.begin(), ded.end(), d1) - ded.begin();

            if(ded[index] != d1)
                index--;

            //cout<<index<<"\n";
            if(index < 0)
                cout<<"Go Sleep\n";

            else if(probs[index] < p1)
                cout<<"Go Sleep\n";

            else
                cout<<"Go Camp\n";

        }
    }

    return 0;
}
link

answered 26 Dec '18, 08:04

naduhrin78's gravatar image

3★naduhrin78
11
accept rate: 0%

edited 26 Dec '18, 08:08

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×13

question asked: 24 Dec '18, 11:25

question was seen: 210 times

last updated: 26 Dec '18, 08:08