結果
| 問題 |
No.999 てん vs. ほむ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-05 19:22:32 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 36 ms / 2,000 ms |
| コード長 | 512 bytes |
| コンパイル時間 | 2,443 ms |
| コンパイル使用メモリ | 195,468 KB |
| 最終ジャッジ日時 | 2025-01-10 06:58:48 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
9 | int n; scanf("%d",&n);
| ~~~~~^~~~~~~~~
main.cpp:11:25: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | rep(i,2*n) scanf("%d",&a[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using lint=long long;
int main(){
int n; scanf("%d",&n);
vector<int> a(2*n);
rep(i,2*n) scanf("%d",&a[i]);
lint total=accumulate(a.begin(),a.end(),0LL);
vector<lint> lsum(2*n+1),rsum(2*n+1);
rep(i,2*n){
lsum[i+1]=lsum[i]+(i%2==0?a[i]:0);
}
for(int i=2*n;i>0;i--){
rsum[i-1]=rsum[i]+(i%2==0?a[i-1]:0);
}
lint res=0;
rep(i,n+1) res=max(res,lsum[2*i]+rsum[2*i]);
printf("%lld\n",2*res-total);
return 0;
}