Submission #1513740
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[]a=new long[n]; for(int i=0;i<n;i++){ a[i]=sc.nextLong(); } int[] count=new int[n]; for(int i=0;i<n;i++){ int left=1; int right=1; while(i-left>=0 && a[i-left]>a[i]){ left++; } while(i+right<=n-1 && a[i+right]>a[i]){ right++; } count[i]=right*left; } long ans=0; for(int i=0;i<n;i++){ ans+=a[i]*count[i]; } System.out.println(ans); } }
Submission Info
Submission Time | |
---|---|
Task | B - Minimum Sum |
User | kwkm0429 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 620 Byte |
Status | WA |
Exec Time | 2109 ms |
Memory | 65768 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 400 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0, example1, example2 |
All | corner0, corner1, corner2, corner3, example0, example1, example2, maxrand0, maxrand1, maxrand2, rand0, rand1, rand2 |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
corner0 | TLE | 2109 ms | 65380 KB |
corner1 | TLE | 2109 ms | 63424 KB |
corner2 | AC | 103 ms | 22100 KB |
corner3 | TLE | 2109 ms | 61460 KB |
example0 | AC | 94 ms | 19668 KB |
example1 | AC | 92 ms | 19284 KB |
example2 | AC | 90 ms | 21844 KB |
maxrand0 | WA | 548 ms | 61012 KB |
maxrand1 | WA | 544 ms | 65768 KB |
maxrand2 | WA | 555 ms | 63536 KB |
rand0 | AC | 104 ms | 21972 KB |
rand1 | AC | 93 ms | 18772 KB |
rand2 | AC | 96 ms | 19796 KB |