結果
| 問題 |
No.1374 Absolute Game
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-10-02 09:24:36 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 719 bytes |
| コンパイル時間 | 1,821 ms |
| コンパイル使用メモリ | 196,864 KB |
| 最終ジャッジ日時 | 2025-02-17 04:00:36 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 18 WA * 8 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:23:11: warning: overflow in conversion from ‘double’ to ‘ll’ {aka ‘int’} changes value from ‘-1.0e+18’ to ‘-2147483648’ [-Woverflow]
23 | ll an=-1e18;
| ^~~~~
ソースコード
#include<bits/stdc++.h>
#include<time.h>
using namespace std;
using ll = int;
#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define all(A) A.begin(),A.end()
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vvvvll = vector<vvvll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vvvvb = vector<vvvb>;
bool DEB = 0;
int main() {
ll N;
cin>>N;
vll C(N);
rep(i,N)cin>>C[i];
ll an=-1e18;
ll res=0,fes;
sort(all(C));
rep(t,2){
res=0,fes=0;
rep(i,N){
if(i%2==0)res+=C[i];
else fes+=C[i];
}
an=max(an,abs(res)-abs(fes));
reverse(all(C));
}
cout<<an<<endl;
}