/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 99ms 11.344 MiB
#2 Accepted 85ms 10.855 MiB
#3 Accepted 88ms 11.137 MiB
#4 Accepted 88ms 10.734 MiB
#5 Accepted 89ms 11.008 MiB
#6 Accepted 88ms 11.113 MiB
#7 Accepted 89ms 10.953 MiB
#8 Accepted 86ms 11.367 MiB
#9 Accepted 85ms 10.957 MiB
#10 Accepted 89ms 11.109 MiB
#11 Accepted 90ms 10.891 MiB
#12 Accepted 88ms 11.176 MiB
#13 Accepted 88ms 10.973 MiB
#14 Accepted 99ms 11.207 MiB
#15 Accepted 96ms 11.035 MiB
#16 Accepted 91ms 11.105 MiB
#17 Accepted 92ms 10.832 MiB
#18 Accepted 89ms 11.078 MiB
#19 Accepted 89ms 10.941 MiB
#20 Accepted 97ms 11.066 MiB
#21 Accepted 259ms 22.523 MiB
#22 Accepted 668ms 53.215 MiB
#23 Accepted 602ms 51.656 MiB
#24 Accepted 624ms 52.461 MiB
#25 Accepted 902ms 85.516 MiB
#26 Accepted 529ms 51.578 MiB
#27 Accepted 284ms 30.992 MiB
#28 Accepted 738ms 51.203 MiB
#29 Accepted 706ms 52.34 MiB
#30 Accepted 753ms 84.543 MiB
#31 Accepted 800ms 63.195 MiB
#32 Accepted 758ms 85.184 MiB
#33 Accepted 682ms 72.184 MiB
#34 Accepted 902ms 57.781 MiB
#35 Accepted 704ms 83.812 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);
                needReplace = (i + 1) - index.get(0) + 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 16:05:07
Judged At
2024-11-11 02:28:34
Judged By
Score
100
Total Time
902ms
Peak Memory
85.516 MiB