Submission #1513606
Source Code Expand
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(); long x=sc.nextLong(); long[]a=new long[n]; for(int i=0;i<n;i++){ a[i]=sc.nextLong(); } long sum_time=Long.MAX_VALUE; long[][] b=new long[n][n]; for(int i=0;i<n;i++){ b[0][i]=a[i]; } for(int k=0;k<n;k++){ if(k!=0){ for(int i=0;i<n;i++){ int pre=0; if(i-k<0)pre=i-k+n; else pre=i-k; b[k][i]=Math.min(b[k-1][i], a[pre]); } } long sum=0; for(int i=0;i<n;i++){ sum+=b[k][i]; } sum+=(long)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 | 400 |
Code Size | 777 Byte |
Status | AC |
Exec Time | 263 ms |
Memory | 82632 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 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 | 93 ms | 21844 KB |
0_01.txt | AC | 94 ms | 20692 KB |
0_02.txt | AC | 105 ms | 25044 KB |
1_00.txt | AC | 202 ms | 76032 KB |
1_01.txt | AC | 210 ms | 78524 KB |
1_02.txt | AC | 251 ms | 78576 KB |
1_03.txt | AC | 248 ms | 80368 KB |
1_04.txt | AC | 242 ms | 82036 KB |
1_05.txt | AC | 241 ms | 76788 KB |
1_06.txt | AC | 248 ms | 80124 KB |
1_07.txt | AC | 238 ms | 80688 KB |
1_08.txt | AC | 250 ms | 78604 KB |
1_09.txt | AC | 239 ms | 78056 KB |
1_10.txt | AC | 231 ms | 54612 KB |
1_11.txt | AC | 248 ms | 77784 KB |
1_12.txt | AC | 263 ms | 81080 KB |
1_13.txt | AC | 218 ms | 53716 KB |
1_14.txt | AC | 259 ms | 78808 KB |
1_15.txt | AC | 235 ms | 54636 KB |
1_16.txt | AC | 219 ms | 53356 KB |
1_17.txt | AC | 242 ms | 82632 KB |