Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test case issue [Histogram] #135

Open
aburifat opened this issue May 4, 2022 · 0 comments
Open

Test case issue [Histogram] #135

aburifat opened this issue May 4, 2022 · 0 comments

Comments

@aburifat
Copy link

aburifat commented May 4, 2022

Please provide the information below:

  1. Problem Link: https://lightoj.com/problem/histogram
  2. Your concern, describe the issue: Weak dataset. The judge accepted the code which didn't provide an entirely correct answer.
  3. Your code or submission link: https://lightoj.com/submission/2315348
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MX 30030
ll arr[MX];
int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	ll t=1;
	cin>>t;
	for(ll T=1;T<=t;T++){
		ll ans=0;
		ll n;
		cin>>n;
		for(ll i=0;i<n;i++){
			cin>>arr[i];
		}
		stack<ll>st;
		ll left[MX],right[MX];
		for(ll i=0;i<n;i++){
			while(!st.empty()){
				if(arr[st.top()]>=arr[i])st.pop();
				else break;
			}
			if(st.empty()){
				left[i]=0;
			}else{
				left[i]=(st.top())+1;
			}
			st.push(i);
		}
		while(!st.empty())st.pop();
		for(ll i=n-1;i>=0;i--){
			while(!st.empty()){
				if(arr[st.top()]>=arr[i])st.pop();
				else break;
			}
			if(st.empty()){
				right[i]=n-1;
			}else{
				right[i]=(st.top())-1;
			}
			st.push(i);
		}
		for(ll i=0;i<n-1;i++){
			ll val=abs(right[i]-left[i])+1;
			val*=arr[i];
			ans=max(ans,val);
		}
		cout<<"Case "<<T<<": "<<ans<<endl;
	}
	return 0;
}
  1. Test case content: The test case for which this code fails to give the correct answer:
Input:
1
1
1

Expected Output:
Case 1: 1

Code Output:
Case 1: 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant