Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

WALK Solution not accepted.....

$
0
0

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..


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>