Guest User

jooooe

a guest
Nov 9th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. import java.util.ArrayList;
  2. import java.util.Scanner;
  3.  
  4. public class Main {
  5.  
  6. static int time = 1000000000;
  7. static int answer = 1000000000;
  8. static int prepare = 1000000000;
  9.  
  10. private static Scanner scan = new Scanner(System.in);
  11.  
  12. static ArrayList<Integer> second = new ArrayList<Integer>();
  13. public static void main(String[] args){
  14. int quests = scan.nextInt();
  15.  
  16. int[] timeArray = parseTime(quests);
  17. findDuplicates(timeArray);
  18.  
  19. if(second.size() > 1){
  20. parsePrepare(quests);
  21. }else{
  22. answer = second.get(0);
  23. }
  24. System.out.println(answer+1);
  25. }
  26. private static int[] parseTime(int n){
  27. int[] timeArray = new int[n];
  28. for(int i = 0; i < n; i++) {
  29. timeArray[i] = scan.nextInt();
  30. if(timeArray[i] < time){
  31. time = timeArray[i];
  32. }
  33. }
  34. return timeArray;
  35. }
  36. private static void findDuplicates(int[] array){
  37. for(int i = 0; i< array.length; i++){
  38. if(array[i] == time){
  39. second.add(i);
  40. }
  41. }
  42. }
  43.  
  44. private static void parsePrepare(int n){
  45. int v = 0;
  46. int element = second.get(v);
  47. for(int i = 0; i < n; i++){
  48. int tmp = scan.nextInt();
  49. if(element == i && tmp <= prepare){
  50. answer = i;
  51. v++;
  52. if(v < second.size()){
  53. element = second.get(v);
  54. }else {
  55. break;
  56. }
  57. }
  58. }
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment