/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 97ms 15.262 MiB
#2 Accepted 98ms 15.215 MiB
#3 Accepted 98ms 15.273 MiB
#4 Accepted 96ms 15.383 MiB
#5 Accepted 98ms 15.289 MiB
#6 Accepted 97ms 15.281 MiB
#7 Accepted 97ms 15.258 MiB
#8 Accepted 97ms 15.301 MiB
#9 Accepted 97ms 15.32 MiB
#10 Wrong Answer 97ms 15.355 MiB
#11 Accepted 95ms 15.219 MiB
#12 Accepted 97ms 15.219 MiB
#13 Accepted 103ms 15.281 MiB
#14 Accepted 108ms 15.398 MiB
#15 Accepted 106ms 15.219 MiB
#16 Accepted 101ms 15.215 MiB
#17 Accepted 105ms 15.402 MiB
#18 Accepted 101ms 15.223 MiB
#19 Accepted 102ms 15.359 MiB
#20 Accepted 104ms 15.215 MiB
#21 Accepted 231ms 23.461 MiB
#22 Accepted 864ms 54.473 MiB
#23 Accepted 834ms 58.18 MiB
#24 Accepted 908ms 54.891 MiB
#25 Time Exceeded ≥1133ms ≥62.852 MiB

Code

import java.util.Scanner;
import java.util.TreeMap;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;

public class Main {
    
    static Scanner in = new Scanner(System.in);
    
    static int n, h, w, testCases, k;
    
    static char x[];
    
    static long a[];
    
    static void solve() {
        
        List<Long> list = new ArrayList<>();
        
        for(int i = 0; i < n; ++i) {
            
            list.add(a[i]);
            
        } 
        
        Collections.sort(list);
        
        List<Integer> index = new ArrayList<>();
        
        int needReplace = 0, len = 0;
        
        for(int i = 0, j = 0; i < n; ++i) {
            
            if(list.get(i) != a[i]) {
                
                ++needReplace;
                index.add(i + 1);
                j = 1;
                
            }
            
        }
        
        if(needReplace > k) {
            
            System.out.println("NO");
            
        } else {
            
            System.out.println("YES");
            System.out.println(index.get(0) + " " + index.get(index.size() - 1));
            
        }
        
    }
    
  public static void main(String args[]) {
   
      testCases = 1;
      
      for(int t = 0; t < testCases; ++t) {
          
          input();
          solve();
          
      }
   
  }
  
  private static void input() {
      
      n = in.nextInt();
      k = in.nextInt();
      
      a = new long[n];
      
      for(int i = 0; i < n; ++i) {
          
          a[i] = in.nextLong();
          
      }

  }
  
}

Information

Submit By
Type
Submission
Problem
P1120 Stairway to the Skyline
Contest
Brain Booster #7
Language
Java 8 (OpenJDK 1.8.0_422)
Submit At
2024-11-05 15:57:24
Judged At
2024-11-05 15:57:24
Judged By
Score
64
Total Time
≥1133ms
Peak Memory
≥62.852 MiB