Ejemplo n.º 1
0
 private static void setStream(String in, String out) {
   try {
     System.setIn(new BufferedInputStream(new FileInputStream(in)));
     System.setOut(new PrintStream(out));
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Ejemplo n.º 2
0
 void run() throws Exception {
   in = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
   out = new PrintWriter(System.out);
   long s = System.currentTimeMillis();
   solve();
   out.flush();
   //		pr(System.currentTimeMillis() - s + "ms");
 }
Ejemplo n.º 3
0
 public static void main(String[] args) {
   InputReader in = new InputReader(System.in);
   OutputWriter out = new OutputWriter(System.out);
   A1Task solver = new A1Task();
   solver.solve(in, out);
   out.close();
   System.exit(0);
 }
Ejemplo n.º 4
0
  void run() {
    Scanner sc = new Scanner(System.in);
    int oo = sc.nextInt();
    for (int o = 1; o <= oo; o++) {
      que = new PriorityQueue<E>();
      int n = sc.nextInt();
      tank = new Tank();
      count = 0;
      int[] h = new int[n + 3], b = new int[n + 3];
      h[0] = 100;
      b[0] = 0;
      h[n + 1] = 50;
      b[n + 1] = 100;
      h[n + 2] = 50;
      b[n + 2] = INF;
      for (int i = 1; i <= n; i++) {
        b[i] = sc.nextInt();
        h[i] = sc.nextInt();
      }
      n += 3;
      for (int i = 1; i < n; i++) {
        tank.bs.add(new Box(b[i - 1], b[i], h[i - 1], h[i], 0, 0));
      }
      int m = sc.nextInt();
      for (int i = 0; i < m; i++) {
        int f = sc.nextInt();
        double a = sc.nextDouble() / 30;
        for (Box box : tank.bs) {
          if (box.b1 < f && f < box.b2) box.f += a;
        }
      }
      debug(tank.bs);

      int l = sc.nextInt();
      res = new double[l];
      for (int i = 0; i < l; i++) {
        que.offer(new W(sc.nextInt(), sc.nextDouble(), i));
      }
      que.offer(tank.nextEvent());
      debug(que.size());
      while (!que.isEmpty()) {
        if (res[0] < 0) System.exit(1);
        que.poll().go();
        debug(que.peek().time());
        debug(tank.bs);
        debug(res);
        debug();
        if (count == l) break;
      }
      for (double r : res) {
        System.out.println(r);
      }
    }
  }
Ejemplo n.º 5
0
 public static void main(String[] args) throws IOException {
   // InputStream inputStream = new FileInputStream("replaceme.in");
   // OutputStream outputStream = new FileOutputStream("replaceme.out");
   /////////////////////////////////////////////////////////////////////
   InputStream inputStream = System.in;
   OutputStream outputStream = System.out;
   InputReader in = new InputReader(inputStream);
   OutputWriter out = new OutputWriter(outputStream);
   Task solver = new Task();
   solver.solve(1, in, out);
   out.close();
   System.exit(0);
 }
 void run() throws Exception {
   long s = System.currentTimeMillis();
   solve();
   out.flush();
   pr(System.currentTimeMillis() - s + "ms");
 }
public class _336_D_Bear_Vasily_and_Beautiful_Strings {
  // ->solution screencast http://youtu.be/oHg5SJYRHA0
  public void solve() {
    int n = ni();
    long res = 0;

    out.println(res);
  }

  // IO methods

  void run() throws Exception {
    long s = System.currentTimeMillis();
    solve();
    out.flush();
    pr(System.currentTimeMillis() - s + "ms");
  }

  public static void main(String[] args) throws Exception {
    new _336_D_Bear_Vasily_and_Beautiful_Strings().run();
  }

  InputStream in = System.in;
  PrintWriter out = new PrintWriter(System.out);

  private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
  private byte[] inbuf = new byte[1024];
  private int lenbuf = 0, ptrbuf = 0;

  private int readByte() {
    if (lenbuf == -1) throw new InputMismatchException();
    if (ptrbuf >= lenbuf) {
      ptrbuf = 0;
      try {
        lenbuf = in.read(inbuf);
      } catch (IOException e) {
        throw new InputMismatchException();
      }
      if (lenbuf <= 0) return -1;
    }
    return inbuf[ptrbuf++];
  }

  private boolean isSpaceChar(int c) {
    return !(c >= 33 && c <= 126);
  }

  private int skip() {
    int b;
    while ((b = readByte()) != -1 && isSpaceChar(b)) ;
    return b;
  }

  public String ns() {
    int b = skip();
    StringBuilder sb = new StringBuilder();
    while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != // ' ')
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  public char[] ns(int n) {
    char[] buf = new char[n];
    int b = skip(), p = 0;
    while (p < n && !(isSpaceChar(b))) {
      buf[p++] = (char) b;
      b = readByte();
    }
    return n == p ? buf : Arrays.copyOf(buf, p);
  }

  public char[][] nm(int n, int m) {
    char[][] map = new char[n][];
    for (int i = 0; i < n; i++) map[i] = ns(m);
    return map;
  }

  public int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++) a[i] = ni();
    return a;
  }

  public int ni() {
    int num = 0, b;
    boolean minus = false;
    while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
    if (b == '-') {
      minus = true;
      b = readByte();
    }

    while (true) {
      if (b >= '0' && b <= '9') {
        num = num * 10 + (b - '0');
      } else {
        return minus ? -num : num;
      }
      b = readByte();
    }
  }

  public long nl() {
    long num = 0;
    int b;
    boolean minus = false;
    while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    while (true) {
      if (b >= '0' && b <= '9') {
        num = num * 10 + (b - '0');
      } else {
        return minus ? -num : num;
      }
      b = readByte();
    }
  }

  void pr(Object... ob) {
    if (!oj) System.out.println(Arrays.deepToString(ob).replace("],", "],\n"));
  }
}
Ejemplo n.º 8
0
public class Main6 {

  public void solve() {
    //		Scanner sc = new Scanner(System.in);
    //		int n = Integer.parseInt(sc.nextLine());
    //		n = 10000;
    pr("\n".getBytes());
    int n = ni();
    //		int xx=100000;
    while (n != 0) {
      String s = ns1();
      //			int size = (int)(Math.random()*10000);
      //			char [] axx = new char[size];
      //			for (int i = 0; i < axx.length; i++) {
      //				char ccc = (char)((Math.random()*('z'-'a'))+'a');
      ////				pr(ccc);
      //				axx[i]=ccc;
      //			}
      //			String s =new String(axx);
      //			for (int i = 0; i < 1000000; i++) {
      //				s+='x';
      //			}
      //			int[] xa = new int[1000000000];
      //			pr(s);
      int a = 0;
      HashMap<Character, Integer> set = new HashMap<Character, Integer>();
      //			int [] alf= new int[128];
      int r = 0;
      for (int i = 0; i < s.length(); i++) {
        //				pr(set);
        //				char that = s.charAt(a);
        char thix = s.charAt(i);
        if (set.size() < n) {
          Integer ax = set.get(thix);
          if (ax == null) {
            set.put(thix, 1);
          } else set.put(thix, ax + 1);

        } else if (set.size() == n) {
          if (!set.containsKey(thix)) {
            while (set.size() == n && a < s.length()) {
              char that = s.charAt(a);
              if (set.containsKey(that) && set.get(that) > 1) set.put(that, set.get(that) - 1);
              else set.remove(that);
              a++;
            }
            set.put(thix, 1);
          } else set.put(thix, set.get(thix) + 1);
        }
        int newr = i - a + 1;
        //				pr(newr, set,a,i,s.substring(a,i));
        if (newr > r) {
          //					pr()
          //					pr(set,a,i,s.substring(a,i));
          r = newr;
        }
        //				r=max(r,);
      }
      out.println(r);
      //			n = (int)(Math.random()*128);
      n = ni();
    }
  }

  void run() throws Exception {
    in = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
    out = new PrintWriter(System.out);
    long s = System.currentTimeMillis();
    solve();
    out.flush();
    //		pr(System.currentTimeMillis() - s + "ms");
  }

  public static void main(String[] args) throws Exception {
    new Main6().run();
  }

  InputStream in;
  PrintWriter out;
  String INPUT = "";

  private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
  private byte[] inbuf = new byte[1024];
  private int lenbuf = 0, ptrbuf = 0;

  private int readByte() {
    if (lenbuf == -1) throw new InputMismatchException();
    if (ptrbuf >= lenbuf) {
      ptrbuf = 0;
      try {
        lenbuf = in.read(inbuf);
      } catch (IOException e) {
        throw new InputMismatchException();
      }
      if (lenbuf <= 0) return -1;
    }
    return inbuf[ptrbuf++];
  }

  private boolean isSpaceChar(int c) {
    return !(c >= 33 && c <= 126);
  }

  private int skip() {
    int b;
    while ((b = readByte()) != -1 && isSpaceChar(b)) ;
    return b;
  }

  private String ns() {
    int b = skip();
    StringBuilder sb = new StringBuilder();
    while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != // ' ')
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  private String ns1() {
    int b = skip();
    StringBuilder sb = new StringBuilder();
    while (!(isSpaceChar(b) && b != ' ')) { // when nextLine,
      sb.appendCodePoint(b);
      b = readByte();
    }
    return sb.toString();
  }

  private int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++) a[i] = ni();
    return a;
  }

  private int ni() {
    int num = 0, b;
    boolean minus = false;
    while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
    if (b == '-') {
      minus = true;
      b = readByte();
    }

    while (true) {
      if (b >= '0' && b <= '9') {
        num = num * 10 + (b - '0');
      } else {
        return minus ? -num : num;
      }
      b = readByte();
    }
  }

  private long nl() {
    long num = 0;
    int b;
    boolean minus = false;
    while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-')) ;
    if (b == '-') {
      minus = true;
      b = readByte();
    }
    while (true) {
      if (b >= '0' && b <= '9') {
        num = num * 10 + (b - '0');
      } else {
        return minus ? -num : num;
      }
      b = readByte();
    }
  }

  void pr(Object... ob) {
    if (!oj) System.out.println(Arrays.deepToString(ob).replace("],", "],\n"));
  }
}