Don't know where is it getting wrong answers. HELP!

Revision en2, by vishwakarmavishal1999, 2021-01-18 18:43:43

Link : https://atcoder.jp/contests/keyence2021/tasks/keyence2021_a

I tried all the types of input and for me, it is giving all the correct answers. on submission it is giving me "Wrong answers" error. I don't know where. IF YOU KNOW WHERE IS IT GETTING WRONG IN MY PROGRAM. HELP ME TO CORRECT IT.

My code : #include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long int n; cin>>n; vector a(n); vector b(n); vector c(n); for(auto &i:a) { cin>>i; }
for(auto &i:b) { cin>>i; }

long long int max1 = a[0];
    long long int max2 = b[0];
    long long int res, pre_res;
    c[0] = 1LL*max1*max2;

    long long int m = c[0];
    for(long int i = 1 ; i < n; i++)
    {
        pre_res =1LL*max1*max2;
        max1 = max(max1,a[i]);
        if(max1>a[i])
        {
            max2 = max(max2,b[i]);
        }
        else {max2 = b[i];}
        res = 1LL*max1*max2;
        if(res > pre_res)
        {
            c[i] = res;
        }
        else {c[i] = pre_res;}
    }


    for(auto i:c)
    {
        cout<<i<<endl;
    }
    return 0;
}
Tags #help error, #basics

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English vishwakarmavishal1999 2021-01-18 18:50:15 148
en3 English vishwakarmavishal1999 2021-01-18 18:44:24 52
en2 English vishwakarmavishal1999 2021-01-18 18:43:43 184
en1 English vishwakarmavishal1999 2021-01-18 18:39:36 1330 Initial revision (published)