/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 94ms 11.891 MiB
#2 Accepted 91ms 11.289 MiB
#3 Accepted 90ms 11.312 MiB
#4 Accepted 90ms 11.445 MiB
#5 Accepted 91ms 11.199 MiB
#6 Accepted 91ms 11.332 MiB
#7 Accepted 90ms 10.945 MiB
#8 Accepted 93ms 11.031 MiB
#9 Accepted 91ms 11.504 MiB
#10 Accepted 91ms 11.391 MiB
#11 Accepted 90ms 11.281 MiB
#12 Accepted 91ms 11.133 MiB
#13 Accepted 93ms 11.215 MiB
#14 Accepted 98ms 11.438 MiB
#15 Accepted 98ms 11.406 MiB
#16 Accepted 94ms 11.129 MiB
#17 Accepted 96ms 11.578 MiB
#18 Accepted 94ms 11.449 MiB
#19 Accepted 96ms 11.262 MiB
#20 Accepted 97ms 11.066 MiB
#21 Accepted 214ms 23.23 MiB
#22 Accepted 642ms 54.281 MiB
#23 Accepted 648ms 52.312 MiB
#24 Accepted 572ms 53.406 MiB
#25 Accepted 904ms 86.398 MiB
#26 Accepted 490ms 52.645 MiB
#27 Accepted 263ms 29.84 MiB
#28 Accepted 649ms 52.766 MiB
#29 Accepted 657ms 51.906 MiB
#30 Accepted 665ms 87.707 MiB
#31 Accepted 779ms 65.844 MiB
#32 Accepted 708ms 86.016 MiB
#33 Accepted 610ms 71.668 MiB
#34 Accepted 715ms 52.203 MiB
#35 Accepted 657ms 87.621 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-05 16:05:07
Judged By
Score
100
Total Time
904ms
Peak Memory
87.707 MiB