/ SeriousOJ /

Record Detail

Time Exceeded


  
# Status Time Cost Memory Cost
#1 Accepted 96ms 11.008 MiB
#2 Accepted 98ms 10.824 MiB
#3 Accepted 98ms 10.898 MiB
#4 Accepted 94ms 10.832 MiB
#5 Accepted 99ms 10.879 MiB
#6 Accepted 97ms 10.898 MiB
#7 Accepted 96ms 10.785 MiB
#8 Accepted 94ms 10.902 MiB
#9 Accepted 98ms 11.125 MiB
#10 Wrong Answer 102ms 10.848 MiB
#11 Accepted 96ms 10.918 MiB
#12 Accepted 94ms 10.895 MiB
#13 Accepted 100ms 10.977 MiB
#14 Accepted 102ms 11.148 MiB
#15 Accepted 102ms 10.98 MiB
#16 Accepted 94ms 10.895 MiB
#17 Accepted 106ms 11.012 MiB
#18 Accepted 102ms 10.98 MiB
#19 Accepted 104ms 10.965 MiB
#20 Accepted 99ms 10.984 MiB
#21 Accepted 279ms 20.824 MiB
#22 Accepted 740ms 51.379 MiB
#23 Accepted 686ms 52.516 MiB
#24 Accepted 646ms 51.961 MiB
#25 Time Exceeded ≥1012ms ≥85.262 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-11 02:29:07
Judged By
Score
64
Total Time
≥1012ms
Peak Memory
≥85.262 MiB