This test case is accepted for two different programs…even the O/P of both programs for a similar test case is different
Both solutions gets AC!!
#include <bits/stdc++.h>
#define int long long
#define MOD 1000000007
#define INF 1000000000000
using namespace std;
signed main()
{
int t;
cin>>t;
while(t–){
int n;
cin>>n;
int arr[n], mn = INT_MAX, count = 0;
for(int i=0; i<n; i++) {
int x;
cin>>x;
mn = min(mn, x);
count+=mn;
}
cout<<count<<endl;
}
return 0;
}
1
6
7 8 6 3 3 4
this code gives O/P = 29
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ll t;
cin>>t;
while(t–){
ll n;
cin>>n;
ll a[n],mini[n];
for(ll int i=0;i<n;i++)
cin>>a[i];
mini[0]=a[0];
for(ll int i=1;i<n;i++)
{
mini[i]=min(mini[i-1],a[i]);
}
ll ans=0,t=mini[n-1];
ans+=(tn);
for(ll int i=n-1;i>=0;i–)
{
if(mini[i]!=t)
{
ans+=(a[i]-t)(i+1);
t=mini[i];
}
}
cout<<ans<<endl;
}
return 0;
}
1
6
7 8 6 3 3 4
this code gives O/P = 31
Both solutions gets AC!!