Submission #1513601
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=Integer.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 | 0 |
Code Size | 778 Byte |
Status | WA |
Exec Time | 256 ms |
Memory | 80888 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 | 90 ms | 19796 KB |
0_01.txt | AC | 90 ms | 22100 KB |
0_02.txt | AC | 94 ms | 21844 KB |
1_00.txt | AC | 227 ms | 79488 KB |
1_01.txt | AC | 221 ms | 74444 KB |
1_02.txt | WA | 225 ms | 80888 KB |
1_03.txt | WA | 220 ms | 76312 KB |
1_04.txt | WA | 238 ms | 76548 KB |
1_05.txt | WA | 233 ms | 77972 KB |
1_06.txt | WA | 243 ms | 78680 KB |
1_07.txt | WA | 240 ms | 78712 KB |
1_08.txt | WA | 256 ms | 76940 KB |
1_09.txt | WA | 241 ms | 76796 KB |
1_10.txt | AC | 212 ms | 51028 KB |
1_11.txt | AC | 237 ms | 78952 KB |
1_12.txt | WA | 235 ms | 76964 KB |
1_13.txt | WA | 220 ms | 50644 KB |
1_14.txt | WA | 240 ms | 78316 KB |
1_15.txt | WA | 216 ms | 50532 KB |
1_16.txt | AC | 221 ms | 51412 KB |
1_17.txt | WA | 234 ms | 77284 KB |