Submission #725534

#TimeUsernameProblemLanguageResultExecution timeMemory
725534browntoadExhibition (JOI19_ho_t2)C++14
Compilation error
0 ms0 KiB
import java.util.ArrayList; import java.util.Collections; import java.util.Scanner; import java.util.Arrays; import java.util.Comparator; class Pair { int x; int y; // Constructor public Pair(int x, int y) { this.x = x; this.y = y; } } class ArrayOfPairsSorter { static void sort(Pair[] arr) { Comparator<Pair> comparator = new Comparator<>() { @Override public int compare(Pair p1, Pair p2) { if (p1.y < p2.y) return -1; else if (p1.y == p2.y) return 0; else return 1; } }; Arrays.sort(arr, comparator); } } class joi2019_ho_t2 { public static void main(String[] args){ Scanner scanner = new Scanner(System.in); int N = scanner.nextInt(); int M = scanner.nextInt(); Pair[] pictures = new Pair[N]; ArrayList<Integer> frame = new ArrayList<Integer>(); for (int i=0; i<N; i++) { pictures[i] = new Pair(scanner.nextInt(), scanner.nextInt()); } for (int i=0; i<M; i++) { frame.add(scanner.nextInt()); } ArrayOfPairsSorter.sort(pictures); Collections.sort(frame); int paintingCounter = N; int frameCounter = M-1; for (int i=N-1; i>=0; i--) { if (frameCounter >= 0) { if (pictures[i].x <= frame.get(frameCounter)) { frameCounter -= 1; } } } System.out.println(M - 1 - frameCounter); } }

Compilation message (stderr)

joi2019_ho_t2.cpp:22:13: error: stray '@' in program
   22 |             @Override
      |             ^
joi2019_ho_t2.cpp:1:1: error: 'import' does not name a type
    1 | import java.util.ArrayList;
      | ^~~~~~
joi2019_ho_t2.cpp:2:1: error: 'import' does not name a type
    2 | import java.util.Collections;
      | ^~~~~~
joi2019_ho_t2.cpp:3:1: error: 'import' does not name a type
    3 | import java.util.Scanner;
      | ^~~~~~
joi2019_ho_t2.cpp:4:1: error: 'import' does not name a type
    4 | import java.util.Arrays;
      | ^~~~~~
joi2019_ho_t2.cpp:5:1: error: 'import' does not name a type
    5 | import java.util.Comparator;
      | ^~~~~~
joi2019_ho_t2.cpp:12:11: error: expected ':' before 'Pair'
   12 |     public Pair(int x, int y) {
      |           ^~~~~
      |           :
joi2019_ho_t2.cpp:16:2: error: expected ';' after class definition
   16 | }
      |  ^
      |  ;
joi2019_ho_t2.cpp: In constructor 'Pair::Pair(int, int)':
joi2019_ho_t2.cpp:13:14: error: request for member 'x' in '(Pair*)this', which is of pointer type 'Pair*' (maybe you meant to use '->' ?)
   13 |         this.x = x;
      |              ^
joi2019_ho_t2.cpp:14:14: error: request for member 'y' in '(Pair*)this', which is of pointer type 'Pair*' (maybe you meant to use '->' ?)
   14 |         this.y = y;
      |              ^
joi2019_ho_t2.cpp: At global scope:
joi2019_ho_t2.cpp:20:29: error: expected ',' or '...' before 'arr'
   20 |     static void sort(Pair[] arr) {
      |                             ^~~
joi2019_ho_t2.cpp:31:2: error: expected ';' after class definition
   31 | }
      |  ^
      |  ;
joi2019_ho_t2.cpp: In static member function 'static void ArrayOfPairsSorter::sort(Pair*)':
joi2019_ho_t2.cpp:21:9: error: 'Comparator' was not declared in this scope
   21 |         Comparator<Pair> comparator = new Comparator<>() {
      |         ^~~~~~~~~~
joi2019_ho_t2.cpp:21:24: error: expected primary-expression before '>' token
   21 |         Comparator<Pair> comparator = new Comparator<>() {
      |                        ^
joi2019_ho_t2.cpp:21:26: error: 'comparator' was not declared in this scope
   21 |         Comparator<Pair> comparator = new Comparator<>() {
      |                          ^~~~~~~~~~
joi2019_ho_t2.cpp:21:43: error: 'Comparator' does not name a type
   21 |         Comparator<Pair> comparator = new Comparator<>() {
      |                                           ^~~~~~~~~~
joi2019_ho_t2.cpp:21:54: error: expected primary-expression before '>' token
   21 |         Comparator<Pair> comparator = new Comparator<>() {
      |                                                      ^
joi2019_ho_t2.cpp:21:56: error: expected primary-expression before ')' token
   21 |         Comparator<Pair> comparator = new Comparator<>() {
      |                                                        ^
joi2019_ho_t2.cpp:29:9: error: 'Arrays' was not declared in this scope
   29 |         Arrays.sort(arr, comparator);
      |         ^~~~~~
joi2019_ho_t2.cpp:29:21: error: 'arr' was not declared in this scope
   29 |         Arrays.sort(arr, comparator);
      |                     ^~~
joi2019_ho_t2.cpp: At global scope:
joi2019_ho_t2.cpp:35:11: error: expected ':' before 'static'
   35 |     public static void main(String[] args){
      |           ^~~~~~~
      |           :
joi2019_ho_t2.cpp:35:29: error: 'String' has not been declared
   35 |     public static void main(String[] args){
      |                             ^~~~~~
joi2019_ho_t2.cpp:35:38: error: expected ',' or '...' before 'args'
   35 |     public static void main(String[] args){
      |                                      ^~~~
joi2019_ho_t2.cpp:66:2: error: expected ';' after class definition
   66 | }
      |  ^
      |  ;
joi2019_ho_t2.cpp: In static member function 'static void joi2019_ho_t2::main(int*)':
joi2019_ho_t2.cpp:36:9: error: 'Scanner' was not declared in this scope
   36 |         Scanner scanner = new Scanner(System.in);
      |         ^~~~~~~
joi2019_ho_t2.cpp:37:17: error: 'scanner' was not declared in this scope
   37 |         int N = scanner.nextInt();
      |                 ^~~~~~~
joi2019_ho_t2.cpp:40:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   40 |         Pair[] pictures = new Pair[N];
      |             ^
joi2019_ho_t2.cpp:40:13: error: structured binding declaration cannot have type 'Pair'
   40 |         Pair[] pictures = new Pair[N];
      |             ^~
joi2019_ho_t2.cpp:40:13: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
joi2019_ho_t2.cpp:40:13: error: empty structured binding declaration
joi2019_ho_t2.cpp:40:16: error: expected initializer before 'pictures'
   40 |         Pair[] pictures = new Pair[N];
      |                ^~~~~~~~
joi2019_ho_t2.cpp:41:9: error: 'ArrayList' was not declared in this scope
   41 |         ArrayList<Integer> frame = new ArrayList<Integer>();
      |         ^~~~~~~~~
joi2019_ho_t2.cpp:41:19: error: 'Integer' was not declared in this scope
   41 |         ArrayList<Integer> frame = new ArrayList<Integer>();
      |                   ^~~~~~~
joi2019_ho_t2.cpp:41:28: error: 'frame' was not declared in this scope
   41 |         ArrayList<Integer> frame = new ArrayList<Integer>();
      |                            ^~~~~
joi2019_ho_t2.cpp:41:40: error: 'ArrayList' does not name a type
   41 |         ArrayList<Integer> frame = new ArrayList<Integer>();
      |                                        ^~~~~~~~~
joi2019_ho_t2.cpp:41:59: error: expected primary-expression before ')' token
   41 |         ArrayList<Integer> frame = new ArrayList<Integer>();
      |                                                           ^
joi2019_ho_t2.cpp:44:13: error: 'pictures' was not declared in this scope
   44 |             pictures[i] = new Pair(scanner.nextInt(), scanner.nextInt());
      |             ^~~~~~~~
joi2019_ho_t2.cpp:51:27: error: expected unqualified-id before '.' token
   51 |         ArrayOfPairsSorter.sort(pictures);
      |                           ^
joi2019_ho_t2.cpp:53:9: error: 'Collections' was not declared in this scope
   53 |         Collections.sort(frame);
      |         ^~~~~~~~~~~
joi2019_ho_t2.cpp:59:21: error: 'pictures' was not declared in this scope
   59 |                 if (pictures[i].x <= frame.get(frameCounter)) {
      |                     ^~~~~~~~
joi2019_ho_t2.cpp:64:9: error: 'System' was not declared in this scope
   64 |         System.out.println(M - 1 - frameCounter);
      |         ^~~~~~
joi2019_ho_t2.cpp:40:13: warning: unused structured binding declaration [-Wunused-variable]
   40 |         Pair[] pictures = new Pair[N];
      |             ^~
joi2019_ho_t2.cpp:54:5: warning: unused variable 'paintingCounter' [-Wunused-variable]
   54 | int paintingCounter = N;
      |     ^~~~~~~~~~~~~~~