Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Scanner;
- class Book{
- int bookId;
- int score;
- public Book(int bookId,int score){
- this.bookId=bookId;
- this.score=score;
- }
- }
- class Library{
- int libraryId;
- int numberOfBooks;
- int timeToSignup;
- int booksToShipPerDay;
- List<Integer> booksIds;
- public Library(int libraryId, int numberOfBooks, int timeToSignup, int booksToShipPerDay, ArrayList<Integer>booksIds) {
- this.numberOfBooks = numberOfBooks;
- this.timeToSignup = timeToSignup;
- this.booksToShipPerDay = booksToShipPerDay;
- booksIds=new ArrayList<>();
- this.booksIds=booksIds;
- }
- public ArrayList<Book> getChosenOrderedBooks(){
- }
- }
- public class Array{
- public static ArrayList<Library> getChosenSortedLibraries(){
- }
- public static void solveTask(int numberOfBooks, ArrayList<Book> books, int numberOfLibraries,
- ArrayList<Library> libraries, int numberOfDays) throws FileNotFoundException {
- PrintWriter printWriter = new PrintWriter("output.txt");
- ArrayList<Library> chosenLibraries = getChosenSortedLibraries();
- int numberOfChosenLibraries = chosenLibraries.size();
- printWriter.write(numberOfLibraries);
- printWriter.write("\n");
- for (int i = 0; i < numberOfChosenLibraries ; i++) {
- Library chosenLibrary = chosenLibraries.get(i);
- printWriter.write(chosenLibrary.libraryId);
- printWriter.write(" ");
- ArrayList<Book> chosenBooksFromLibrary = chosenLibrary.getChosenOrderedBooks();
- int numBooks = chosenBooksFromLibrary.size();
- printWriter.write(numBooks);
- printWriter.write("\n");
- for (int j = 0; j < numBooks; j++) {
- Book chosenBook = chosenBooksFromLibrary.get(j);
- printWriter.write(chosenBook.bookId);
- printWriter.write(" ");
- }
- printWriter.write("\n");
- }
- printWriter.flush();
- }
- public static void main(String[] args) throws IOException {
- String fileName = "";
- Scanner scanner = new Scanner(new FileReader(fileName));
- int numberOfBooks = scanner.nextInt();
- int numberOfLibraries = scanner.nextInt();
- int numberOfDays = scanner.nextInt();
- ArrayList<Book> books = new ArrayList<>();
- for (int i = 0; i < numberOfBooks; i++) {
- int bookScore = scanner.nextInt();
- Book book = new Book(i,bookScore);
- books.add(book);
- }
- ArrayList<Library> libraries = new ArrayList<>();
- for (int i = 0; i < numberOfLibraries; i++) {
- int numBooksInLibrary = scanner.nextInt();
- int numDaysToSignup = scanner.nextInt();
- int numBooksCanShip = scanner.nextInt();
- ArrayList<Integer> booksIds = new ArrayList<>();
- for (int j = 0; j < numBooksInLibrary; j++) {
- booksIds.add(scanner.nextInt());
- }
- Library library = new Library(i,numBooksInLibrary,numDaysToSignup,numBooksCanShip,booksIds);
- libraries.add(library);
- }
- solveTask(numberOfBooks,books,numberOfLibraries,libraries,numberOfDays);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement