Блог пользователя 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
  • Проголосовать: не нравится

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

==Java Noob

ok, I'm trying to learn Java but am having some early issues here — can someone please tell me why this code returns WA on problem 9 (lots of inputs) but works fine when I revert to the commented out code (with some mods of course) and use what I'm hearing is supposed to be a legacy and discouraged class — StringTokenizer ?

import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer;

public class CROC2013Round2Div2A {

public static void main(String[] args) throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    int n = Integer.parseInt(br.readLine());
    String[] arr = br.readLine().split(" ");

    //StringTokenizer str = new StringTokenizer(br.readLine());
    //int[] arr = new int[n];
    //for (int i = 0; i < n; i++) arr[i] = Integer.valueOf(str.nextToken());

    Arrays.sort(arr);

    for (int i = 1; i < arr.length; i++)
        if (Integer.valueOf(arr[i]) % Integer.valueOf(arr[0]) != 0) {
            System.out.println(-1);
            return;
        }
    System.out.println(arr[0]);
}

}

At first I had even skipped the BufferedReader for just a Scanner but was thinking maybe it was a size constraint... now I'm just all kinds of confused

Полный текст и комментарии »

  • Проголосовать: нравится
  • -18
  • Проголосовать: не нравится

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

==Java Noob

I just tried submitting some practice code from IntelliJ and it seems to be getting a runtime error unless I remove the "Package" line (which intellij doesn't seem to like)

Is there a go around or quick fix?

thanks

Полный текст и комментарии »

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

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

I recently tried using a Tuple in one of my submissions (I won't say which one since it ended up being the wrong move) and got a compiler error. I'm seeing System.Tuple in Mono documentations online and have no issues with using it in MonoDeveloper(Xamarin), but here I get

Invocation failed [COMPILATION_ERROR] Can't compile program.cs: program.cs(11,13): error CS0103: The name `Tuple' does not exist in the current context

Is this a C# 2.0 issue? Seems like it shouldn't be... I mean the (x)=>x.y lambdas seem to work?

Anyone have any ideas? Also, where should I go to see an entire usable library compatible with all the components used by CodeForces for C#, so that I don't hang myself with unsupported classes again in the future?

Thanks

Полный текст и комментарии »

Теги c#, mono
  • Проголосовать: нравится
  • +6
  • Проголосовать: не нравится