結果
| 問題 | No.8103 Range Chmax and Maximize Abs Sum |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-03-31 22:10:58 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,181 bytes |
| コンパイル時間 | 2,321 ms |
| コンパイル使用メモリ | 78,428 KB |
| 実行使用メモリ | 56,968 KB |
| 最終ジャッジ日時 | 2024-09-23 00:53:29 |
| 合計ジャッジ時間 | 14,215 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 3 WA * 21 |
ソースコード
import java.util.*;
import java.io.*;
import java.math.*;
class Main{
static void solve(){
int n = ni();
long [] A = new long[n];
long [] MAX = new long[n];
for(int i = 0 ; i < n ; i ++ ) {
A[i] = (long)Math.abs(nl());
}
MAX[0] = A[0];
for(int i = 1 ; i < n ; i++ ) {
MAX[i] = (long)Math.max(MAX[i-1],A[i]);
}
long ans = 0;
for(int i = 0 ; i < n ; i ++ ) {
ans += MAX[i];
}
output.print(ans);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - //
static int ni(){ return Integer.parseInt(sc.next()); }
static long nl(){ return Long.parseLong(sc.next()); }
static double nd(){ return Double.parseDouble(sc.next()); }
static String ns(){ return sc.next(); }
static BigInteger bi(){ return sc.nextBigInteger(); }
static BigDecimal bd(){ return sc.nextBigDecimal(); }
static PrintWriter output;
static Scanner sc ;
public static void main(String[] args){
output = new PrintWriter(System.out);
sc = new Scanner(System.in);
solve();
output.flush();
}
}