Submission #1119538

#TimeUsernameProblemLanguageResultExecution timeMemory
1119538johuJob Scheduling (CEOI12_jobs)Java
Compilation error
0 ms0 KiB
import java.io.*; import java.util.*; public class Jobs { public static void main(String[] args) throws IOException { FastInputReader reader = new FastInputReader(System.in); int n = reader.nextInt(); int d = reader.nextInt(); int m = reader.nextInt(); if (m <= 300000) { handleSmallCases(reader, n, d, m); } else { handleLargeCases(reader, n, d, m); } } private static void handleSmallCases(FastInputReader reader, int n, int d, int m) throws IOException { List&lt;Pair&gt; a = new ArrayList&lt;&gt;(); for (int i = 1; i &lt;= m; i++) { a.add(new Pair(reader.nextInt(), i)); } a.add(new Pair(1000000000, 0)); a.sort(Comparator.naturalOrder()); int l = 0, r = m; while (r - l &gt; 1) { int mid = (l + r) / 2; int p = 0; for (int i = 1; i &lt;= n; i++) { if (a.get(p).fr + d &lt; i) { break; } int cnt = 0; while (cnt &lt; mid &amp;&amp; p &lt; m &amp;&amp; a.get(p).fr &lt;= i) { cnt++; p++; } } if (p &gt;= m) { r = mid; } else { l = mid; } } System.out.println(r); StringBuilder sb = new StringBuilder(); int p = 0; for (int i = 1; i &lt;= n; i++) { int cnt = 0; while (cnt &lt; r &amp;&amp; p &lt; m &amp;&amp; a.get(p).fr &lt;= i) { sb.append(a.get(p).sc).append(" "); cnt++; p++; } sb.append("0\n"); } System.out.print(sb); } private static void handleLargeCases(FastInputReader reader, int n, int d, int m) throws IOException { int[] fr = new int[m + 1]; int[] sc = new int[m + 1]; for (int i = 1; i &lt;= m; i++) { fr[i] = reader.nextInt(); sc[i] = i; } quickSort(fr, sc, 1, m); int l = 0, r = m; while (r - l &gt; 1) { int mid = (l + r) / 2; int p = 1; for (int i = 1; i &lt;= n; i++) { if (p &gt; m || fr[p] + d &lt; i) break; int cnt = 0; while (cnt &lt; mid &amp;&amp; p &lt;= m &amp;&amp; fr[p] &lt;= i) { cnt++; p++; } } if (p &gt; m) { r = mid; } else { l = mid; } } BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); bw.write(r + "\n"); int p = 1; for (int i = 1; i &lt;= n; i++) { int cnt = 0; while (cnt &lt; r &amp;&amp; p &lt;= m &amp;&amp; fr[p] &lt;= i) { bw.write(sc[p] + " "); cnt++; p++; } bw.write("0\n"); } bw.flush(); } private static void quickSort(int[] fr, int[] sc, int low, int high) { if (low &lt; high) { int pivotIndex = partition(fr, sc, low, high); quickSort(fr, sc, low, pivotIndex - 1); quickSort(fr, sc, pivotIndex + 1, high); } } private static int partition(int[] fr, int[] sc, int low, int high) { int pivot = fr[high]; int i = low - 1; for (int j = low; j &lt; high; j++) { if (fr[j] &lt;= pivot) { i++; swap(fr, sc, i, j); } } swap(fr, sc, i + 1, high); return i + 1; } private static void swap(int[] fr, int[] sc, int i, int j) { int tempFr = fr[i]; fr[i] = fr[j]; fr[j] = tempFr; int tempSc = sc[i]; sc[i] = sc[j]; sc[j] = tempSc; } static class Pair implements Comparable&lt;Pair&gt; { int fr, sc; Pair(int fr, int sc) { this.fr = fr; this.sc = sc; } @Override public int compareTo(Pair other) { return Integer.compare(this.fr, other.fr); } } static class FastInputReader { private final DataInputStream din; private final byte[] buffer; private int bufferPointer, bytesRead; public FastInputReader(InputStream in) { din = new DataInputStream(in); buffer = new byte[1 &lt;&lt; 16]; bufferPointer = bytesRead = 0; } private void fillBuffer() throws IOException { bytesRead = din.read(buffer, 0, buffer.length); bufferPointer = 0; if (bytesRead == -1) buffer[0] = -1; } public int nextInt() throws IOException { int ret = 0; byte c = skipToDigit(); boolean neg = (c == '-'); if (neg) c = read(); do { ret = ret * 10 + c - '0'; } while ((c = read()) &gt;= '0' &amp;&amp; c &lt;= '9'); return neg ? -ret : ret; } private byte skipToDigit() throws IOException { byte c; while ((c = read()) &lt; '0' || c &gt; '9') { if (c == '-') return c; } return c; } private byte read() throws IOException { if (bufferPointer == bytesRead) fillBuffer(); return buffer[bufferPointer++]; } } }

Compilation message (stderr)

jobs.java:20: error: not a statement
        List&lt;Pair&gt; a = new ArrayList&lt;&gt;();
            ^
jobs.java:20: error: not a statement
        List&lt;Pair&gt; a = new ArrayList&lt;&gt;();
                    ^
jobs.java:20: error: '(' or '[' expected
        List&lt;Pair&gt; a = new ArrayList&lt;&gt;();
                                          ^
jobs.java:20: error: illegal start of expression
        List&lt;Pair&gt; a = new ArrayList&lt;&gt;();
                                              ^
jobs.java:20: error: -> expected
        List&lt;Pair&gt; a = new ArrayList&lt;&gt;();
                                                    ^
jobs.java:20: error: not a statement
        List&lt;Pair&gt; a = new ArrayList&lt;&gt;();
                                                  ^
jobs.java:21: error: illegal start of expression
        for (int i = 1; i &lt;= m; i++) {
                              ^
jobs.java:21: error: ')' expected
        for (int i = 1; i &lt;= m; i++) {
                                 ^
jobs.java:21: error: ';' expected
        for (int i = 1; i &lt;= m; i++) {
                                      ^
jobs.java:30: error: ')' expected
        while (r - l &gt; 1) {
                        ^
jobs.java:30: error: not a statement
        while (r - l &gt; 1) {
                          ^
jobs.java:30: error: ';' expected
        while (r - l &gt; 1) {
                           ^
jobs.java:34: error: illegal start of expression
            for (int i = 1; i &lt;= n; i++) {
                                  ^
jobs.java:34: error: ')' expected
            for (int i = 1; i &lt;= n; i++) {
                                     ^
jobs.java:34: error: ';' expected
            for (int i = 1; i &lt;= n; i++) {
                                          ^
jobs.java:35: error: ')' expected
                if (a.get(p).fr + d &lt; i) {
                                       ^
jobs.java:35: error: not a statement
                if (a.get(p).fr + d &lt; i) {
                                         ^
jobs.java:35: error: ';' expected
                if (a.get(p).fr + d &lt; i) {
                                          ^
jobs.java:39: error: ')' expected
                while (cnt &lt; mid &amp;&amp; p &lt; m &amp;&amp; a.get(p).fr &lt;= i) {
                              ^
jobs.java:39: error: not a statement
                while (cnt &lt; mid &amp;&amp; p &lt; m &amp;&amp; a.get(p).fr &lt;= i) {
                                    ^
jobs.java:39: error: illegal start of expression
                while (cnt &lt; mid &amp;&amp; p &lt; m &amp;&amp; a.get(p).fr &lt;= i) {
                                         ^
jobs.java:39: error: not a statement
                while (cnt &lt; mid &amp;&amp; p &lt; m &amp;&amp; a.get(p).fr &lt;= i) {
                                                 ^
jobs.java:39: error: not a statement
                while (cnt &lt; mid &amp;&amp; p &lt; m &amp;&amp; a.get(p).fr &lt;= i) {
                                                        ^
jobs.java:39: error: illegal start of expression
                while (cnt &lt; mid &amp;&amp; p &lt; m &amp;&amp; a.get(p).fr &lt;= i) {
                                                             ^
jobs.java:39: error: not a statement
                while (cnt &lt; mid &amp;&amp; p &lt; m &amp;&amp; a.get(p).fr &lt;= i) {
                                                                               ^
jobs.java:39: error: illegal start of expression
                while (cnt &lt; mid &amp;&amp; p &lt; m &amp;&amp; a.get(p).fr &lt;= i) {
                                                                                   ^
jobs.java:39: error: ';' expected
                while (cnt &lt; mid &amp;&amp; p &lt; m &amp;&amp; a.get(p).fr &lt;= i) {
                                                                                      ^
jobs.java:45: error: ')' expected
            if (p &gt;= m) {
                     ^
jobs.java:45: error: illegal start of expression
            if (p &gt;= m) {
                      ^
jobs.java:45: error: ';' expected
            if (p &gt;= m) {
                         ^
jobs.java:47: error: 'else' without 'if'
            } else {
              ^
jobs.java:56: error: illegal start of expression
        for (int i = 1; i &lt;= n; i++) {
                              ^
jobs.java:56: error: ')' expected
        for (int i = 1; i &lt;= n; i++) {
                                 ^
jobs.java:56: error: ';' expected
        for (int i = 1; i &lt;= n; i++) {
                                      ^
jobs.java:58: error: ')' expected
            while (cnt &lt; r &amp;&amp; p &lt; m &amp;&amp; a.get(p).fr &lt;= i) {
                          ^
jobs.java:58: error: not a statement
            while (cnt &lt; r &amp;&amp; p &lt; m &amp;&amp; a.get(p).fr &lt;= i) {
                              ^
jobs.java:58: error: illegal start of expression
            while (cnt &lt; r &amp;&amp; p &lt; m &amp;&amp; a.get(p).fr &lt;= i) {
                                   ^
jobs.java:58: error: not a statement
            while (cnt &lt; r &amp;&amp; p &lt; m &amp;&amp; a.get(p).fr &lt;= i) {
                                           ^
jobs.java:58: error: not a statement
            while (cnt &lt; r &amp;&amp; p &lt; m &amp;&amp; a.get(p).fr &lt;= i) {
                                                  ^
jobs.java:58: error: illegal start of expression
            while (cnt &lt; r &amp;&amp; p &lt; m &amp;&amp; a.get(p).fr &lt;= i) {
                                                       ^
jobs.java:58: error: not a statement
            while (cnt &lt; r &amp;&amp; p &lt; m &amp;&amp; a.get(p).fr &lt;= i) {
                                                                         ^
jobs.java:58: error: illegal start of expression
            while (cnt &lt; r &amp;&amp; p &lt; m &amp;&amp; a.get(p).fr &lt;= i) {
                                                                             ^
jobs.java:58: error: ';' expected
            while (cnt &lt; r &amp;&amp; p &lt; m &amp;&amp; a.get(p).fr &lt;= i) {
                                                                                ^
jobs.java:73: error: illegal start of expression
        for (int i = 1; i &lt;= m; i++) {
                              ^
jobs.java:73: error: ')' expected
        for (int i = 1; i &lt;= m; i++) {
                                 ^
jobs.java:73: error: ';' expected
        for (int i = 1; i &lt;= m; i++) {
                                      ^
jobs.java:82: error: ')' expected
        while (r - l &gt; 1) {
                        ^
jobs.java:82: error: not a statement
        while (r - l &gt; 1) {
                          ^
jobs.java:82: error: ';' expected
        while (r - l &gt; 1) {
                           ^
jobs.java:86: error: illegal start of expression
            for (int i = 1; i &lt;= n; i++) {
                                  ^
jobs.java:86: error: ')' expected
            for (int i = 1; i &lt;= n; i++) {
                                     ^
jobs.java:86: error: ';' expected
            for (int i = 1; i &lt;= n; i++) {
                                          ^
jobs.java:87: error: ')' expected
                if (p &gt; m || fr[p] + d &lt; i) break;
                         ^
jobs.java:87: error: not a statement
                if (p &gt; m || fr[p] + d &lt; i) break;
                             ^
jobs.java:87: error: not a statement
                if (p &gt; m || fr[p] + d &lt; i) break;
                                               ^
jobs.java:87: error: ';' expected
                if (p &gt; m || fr[p] + d &lt; i) break;
                                                ^
jobs.java:90: error: ')' expected
                while (cnt &lt; mid &amp;&amp; p &lt;= m &amp;&amp; fr[p] &lt;= i) {
                              ^
jobs.java:90: error: not a statement
                while (cnt &lt; mid &amp;&amp; p &lt;= m &amp;&amp; fr[p] &lt;= i) {
                                    ^
jobs.java:90: error: illegal start of expression
                while (cnt &lt; mid &amp;&amp; p &lt;= m &amp;&amp; fr[p] &lt;= i) {
                                         ^
jobs.java:90: error: not a statement
                while (cnt &lt; mid &amp;&amp; p &lt;= m &amp;&amp; fr[p] &lt;= i) {
                                                 ^
jobs.java:90: error: illegal start of expression
                while (cnt &lt; mid &amp;&amp; p &lt;= m &amp;&amp; fr[p] &lt;= i) {
                                                     ^
jobs.java:90: error: illegal start of expression
                while (cnt &lt; mid &amp;&amp; p &lt;= m &amp;&amp; fr[p] &lt;= i) {
                                                              ^
jobs.java:90: error: not a statement
                while (cnt &lt; mid &amp;&amp; p &lt;= m &amp;&amp; fr[p] &lt;= i) {
                                                                          ^
jobs.java:90: error: illegal start of expression
                while (cnt &lt; mid &amp;&amp; p &lt;= m &amp;&amp; fr[p] &lt;= i) {
                                                                              ^
jobs.java:90: error: ';' expected
                while (cnt &lt; mid &amp;&amp; p &lt;= m &amp;&amp; fr[p] &lt;= i) {
                                                                                 ^
jobs.java:96: error: ')' expected
            if (p &gt; m) {
                     ^
jobs.java:96: error: not a statement
            if (p &gt; m) {
                       ^
jobs.java:96: error: ';' expected
            if (p &gt; m) {
                        ^
jobs.java:98: error: 'else' without 'if'
            } else {
              ^
jobs.java:107: error: illegal start of expression
        for (int i = 1; i &lt;= n; i++) {
                              ^
jobs.java:107: error: ')' expected
        for (int i = 1; i &lt;= n; i++) {
                                 ^
jobs.java:107: error: ';' expected
        for (int i = 1; i &lt;= n; i++) {
                                      ^
jobs.java:109: error: ')' expected
            while (cnt &lt; r &amp;&amp; p &lt;= m &amp;&amp; fr[p] &lt;= i) {
                          ^
jobs.java:109: error: not a statement
            while (cnt &lt; r &amp;&amp; p &lt;= m &amp;&amp; fr[p] &lt;= i) {
                              ^
jobs.java:109: error: illegal start of expression
            while (cnt &lt; r &amp;&amp; p &lt;= m &amp;&amp; fr[p] &lt;= i) {
                                   ^
jobs.java:109: error: not a statement
            while (cnt &lt; r &amp;&amp; p &lt;= m &amp;&amp; fr[p] &lt;= i) {
                                           ^
jobs.java:109: error: illegal start of expression
            while (cnt &lt; r &amp;&amp; p &lt;= m &amp;&amp; fr[p] &lt;= i) {
                                               ^
jobs.java:109: error: illegal start of expression
            while (cnt &lt; r &amp;&amp; p &lt;= m &amp;&amp; fr[p] &lt;= i) {
                                                        ^
jobs.java:109: error: not a statement
            while (cnt &lt; r &amp;&amp; p &lt;= m &amp;&amp; fr[p] &lt;= i) {
                                                                    ^
jobs.java:109: error: illegal start of expression
            while (cnt &lt; r &amp;&amp; p &lt;= m &amp;&amp; fr[p] &lt;= i) {
                                                                        ^
jobs.java:109: error: ';' expected
            while (cnt &lt; r &amp;&amp; p &lt;= m &amp;&amp; fr[p] &lt;= i) {
                                                                           ^
jobs.java:120: error: ')' expected
        if (low &lt; high) {
                   ^
jobs.java:120: error: not a statement
        if (low &lt; high) {
                     ^
jobs.java:120: error: ';' expected
        if (low &lt; high) {
                         ^
jobs.java:130: error: not a statement
        for (int j = low; j &lt; high; j++) {
                                 ^
jobs.java:130: error: ')' expected
        for (int j = low; j &lt; high; j++) {
                                     ^
jobs.java:130: error: ';' expected
        for (int j = low; j &lt; high; j++) {
                                          ^
jobs.java:131: error: ')' expected
            if (fr[j] &lt;= pivot) {
                         ^
jobs.java:131: error: illegal start of expression
            if (fr[j] &lt;= pivot) {
                          ^
jobs.java:131: error: ';' expected
            if (fr[j] &lt;= pivot) {
                                 ^
jobs.java:150: error: '{' expected
    static class Pair implements Comparable&lt;Pair&gt; {
                                           ^
jobs.java:150: error: <identifier> expected
    static class Pair implements Comparable&lt;Pair&gt; {
                                                   ^
jobs.java:150: error: <identifier> expected
    static class Pair implements Comparable&lt;Pair&gt; {
                                                      ^
jobs.java:153: error: '.class' expected
        Pair(int fr, int sc) {
                 ^
jobs.java:153: error: ';' expected
        Pair(int fr, int sc) {
                   ^
jobs.java:153: error: ';' expected
        Pair(int fr, int sc) {
                           ^
jobs.java:159: error: ';' expected
        public int compareTo(Pair other) {
                            ^
jobs.java:159: error: ';' expected
        public int compareTo(Pair other) {
                                       ^
jobs.java:171: error: ']' expected
            buffer = new byte[1 &lt;&lt; 16];
                                   ^
jobs.java:171: error: illegal start of expression
            buffer = new byte[1 &lt;&lt; 16];
                                    ^
100 errors