Блог пользователя bdub

Автор bdub, 12 лет назад, По-английски

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!!

Теги c++
  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
12 лет назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Well why do you return 7 in main method?

»
12 лет назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится
for (int i = 0; i < vll.size(); ++i) {
    x = vll[i];
    e += x-y;
    if (e < 0) {
            ret += abs(e);
            e=0;
    }
    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:

text

5 ~
code
5 ~

text
»
12 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

use smth like pasteubuntu to share your code