I am running this solution for 264 Div 2 B and am getting the correct response (4) for problem one, but when I submit it I'm get back "Wrong answer problem 1" and it's telling me the program is returning 0. I've trying unsuccessfully submitting under all three C++ options but I'm not sure why the online grader is returning a different answer than what I get when I run it on my computer here.... can anyone please help me?
include <stdio.h>
include <stdlib.h>
include <stdarg.h>
include <math.h>
include
include
typedef long long ll; typedef unsigned char byte; using namespace std;
int main(int argc, char* argv[]) {
ll n, x, y=0, ret=0, e=0;
vector<ll> vll;
cin >> n;
for (int i =0; i < n; ++i) {
cin >> x;
vll.push_back(x);
}
for (int i = 0; i < vll.size(); ++i) {
x = vll[i];
e += x-y;
if (e < 0) {
ret += abs(e);
e=0;
}
y=x;
}
cout << ret << endl;
return 7;
}
Thanks!!








Well why do you return 7 in main method?
No reason, just was making sure the online grader wasn't pulling it's answer from my return rather than from the cout... was a long shot but had to make sure
I think you should replace
e += x-y;withe += y-x;Statement says about difference in bits between one and all others, not near ones.
And, yes, return 0
P.S. surround your code with 5 tildas:
use smth like pasteubuntu to share your code