Submission #2248556


Source Code Expand

import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] l = new int[n];
		int total=0;
		for(int i = 0;i < n;i++) {
			l[i] = sc.nextInt();
		}
		for(int i=0; i<n-1; i++){
		      for(int j=0; j<(n-1)-i; j++){
		    	  		if(l[j]<l[j+1]){
		    	  			int temp=l[j];
		    	  			l[j]=l[j+1];
		    	  			l[j+1]=temp;
		    	  		}
		      }
		}
		for(int i = 0;i < k;i++) {
			total = total+l[i];
		}
		System.out.println(total);
	}

}

Submission Info

Submission Time
Task B - Snake Toy
User ne290004
Language Java8 (OpenJDK 1.8.0)
Score 200
Code Size 619 Byte
Status AC
Exec Time 95 ms
Memory 22868 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 2
AC × 10
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt
All 00_example_01.txt, 00_example_02.txt, 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 93 ms 21844 KB
00_example_02.txt AC 93 ms 18900 KB
01.txt AC 91 ms 18644 KB
02.txt AC 93 ms 19028 KB
03.txt AC 93 ms 18900 KB
04.txt AC 93 ms 21844 KB
05.txt AC 93 ms 21716 KB
06.txt AC 95 ms 21972 KB
07.txt AC 93 ms 22868 KB
08.txt AC 93 ms 19668 KB