Submission #1513532
Source Code Expand
import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { new Main().solve(); } void solve(){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int x=sc.nextInt(); int[]a=new int[n]; for(int i=0;i<n;i++){ a[i]=sc.nextInt(); } int sum_time=Integer.MAX_VALUE; int[] b=new int[n]; Arrays.fill(b,Integer.MAX_VALUE); for(int k=0;k<n;k++){ for(int i=0;i<n;i++){ for(int j=0;j<=k;j++){ if(i-j<0){ b[i]=Math.min(b[i], a[i-j+n]); }else{ b[i]=Math.min(b[i], a[i-j]); } } } int sum=0; for(int i=0;i<n;i++){ sum+=b[i]; } sum+=k*x; if(sum<sum_time)sum_time=sum; } System.out.println(sum_time); } }
Submission Info
Submission Time | |
---|---|
Task | B - Colorful Slimes |
User | kwkm0429 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 789 Byte |
Status | TLE |
Exec Time | 2109 ms |
Memory | 26080 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 91 ms | 20564 KB |
0_01.txt | AC | 90 ms | 21204 KB |
0_02.txt | AC | 91 ms | 19796 KB |
1_00.txt | TLE | 2109 ms | 22916 KB |
1_01.txt | TLE | 2109 ms | 23680 KB |
1_02.txt | TLE | 2109 ms | 25796 KB |
1_03.txt | TLE | 2109 ms | 23668 KB |
1_04.txt | TLE | 2109 ms | 23816 KB |
1_05.txt | TLE | 2109 ms | 24092 KB |
1_06.txt | TLE | 2109 ms | 25776 KB |
1_07.txt | TLE | 2109 ms | 25104 KB |
1_08.txt | TLE | 2109 ms | 24244 KB |
1_09.txt | TLE | 2109 ms | 24328 KB |
1_10.txt | TLE | 2109 ms | 22904 KB |
1_11.txt | TLE | 2109 ms | 26080 KB |
1_12.txt | TLE | 2109 ms | 23412 KB |
1_13.txt | TLE | 2109 ms | 26064 KB |
1_14.txt | TLE | 2109 ms | 23132 KB |
1_15.txt | TLE | 2109 ms | 25296 KB |
1_16.txt | TLE | 2109 ms | 24204 KB |
1_17.txt | TLE | 2109 ms | 24332 KB |