Need help in detecting Diagnostic Issue

Revision en1, by highcastle, 2020-05-30 16:35:01

Some Uninitialized value is gicing unexpected output ..Need help in identifying the issue The Problem statement goes here Best Vacation is The submissione goes here 81970910

include<bits/stdc++.h>

using namespace std;

define ll long long

define pb push_back

define io ios_base::sync_with_stdio(false);cin.tie(NULL);

define pie acos(-1)

define loop(i,a,n) for(ll i=a;i<n;i++)

define vi vector

define vl vector

define all(a) a.begin(),a.end()

void solve() { #define int long long int n ,x; cin>>n>>x; vi a(2*n); loop(i,0,n) { cin>>a[i]; a[n+i] = a[i]; } vi pre(2*n); pre[0] = a[0]; vl sum(2*n); for(int i = 1 ; i<2*n ; i++) { pre[i] = a[i]+pre[i-1]; } sum[0]=a[0]*(a[0]+1)/2; for(int i = 1; i< 2*n ;i++) { sum[i] = sum[i-1] + a[i]*(a[i]+1)/2; } ll ans = 0 ; for(int i = 0 ; i < 2*n ; i++) { int y = pre[i] — x; auto it = upper_bound(all(pre),y); if(it!=pre.end()) { int j = it — pre.begin(); int diff = pre[i]-pre[j-1] — x; ll here = sum[i]-sum[j-1]; here-=(diff*(diff+1)/2); //cout<<here<<" "<<ans<<endl; //seee(j,here,diff) ans = max(ans,here); } }

cout<<ans<<endl;

}

undef int

int main() { // your code goes here io; solve(); return 0; }

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en6 English highcastle 2020-05-30 16:43:03 2 Tiny change: 'alue is gicing unexpe' -> 'alue is giving unexpe'
en5 English highcastle 2020-05-30 16:37:49 1 Tiny change: 'submissione goes here' -> 'submission goes here'
en4 English highcastle 2020-05-30 16:36:52 0 (published)
en3 English highcastle 2020-05-30 16:36:35 1433
en2 English highcastle 2020-05-30 16:36:01 3
en1 English highcastle 2020-05-30 16:35:01 1756 Initial revision (saved to drafts)