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

×

WALK Solution not accepted.....

Someone please please help me to figure out what is the difference in the outputs of these two code?? my code for the problem

#include <string>
#include <iostream>
#include <limits.h>
using namespace std;

int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string str; getline(cin, str); int tests = atoi(str.c_str()); while(tests--){ long int n; cin >> n; long int values[n], index = 0, max = 0; for(long int i = 0; i < n; i++){ cin >> values[i]; } for(long int i = 0; i < n; i++){ if(values[i] >= max){ max = values[i]; index = i; } } long int total = (max + index); cout << total << endl; } return 0; }

// some other users code

#include<iostream>
#include<bits/stdc++.h>
using namespace std;

int main()
{ int t; cin>>t; while(t--) { long int n,i,w,m=0; cin>>n; for(i=0;i<n;i++) { cin>>w; if(w+i>m) m=w+i; } cout<< m<< endl; } }

Please help to give any test case in which my code fails.... As I tested both are giving same ans in all test cases.. But codechef is not accepting my ans..

asked 13 Jun, 19:40

ch_dktomar's gravatar image

2★ch_dktomar
1
accept rate: 0%

edited 13 Jun, 20:01

vijju123's gravatar image

5★vijju123 ♦
14.4k11653


1

5

7 4 5 6 3

Your answer: 7 Correct answer: 9

link

answered 13 Jun, 20:13

abhineet14's gravatar image

4★abhineet14
4218
accept rate: 16%

thank you very much for your help....

(21 Jun, 18:01) ch_dktomar2★
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:

×197
×5

question asked: 13 Jun, 19:40

question was seen: 73 times

last updated: 21 Jun, 18:01