結果
問題 |
No.2854 -1 Subsequence
|
ユーザー |
![]() |
提出日時 | 2024-08-25 14:09:03 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 853 bytes |
コンパイル時間 | 6,264 ms |
コンパイル使用メモリ | 336,936 KB |
実行使用メモリ | 15,940 KB |
最終ジャッジ日時 | 2024-08-25 14:09:19 |
合計ジャッジ時間 | 9,878 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 30 WA * 10 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:23:42: warning: integer overflow in expression of type 'long long int' results in '-9223372036854775808' [-Woverflow] 23 | vector<vector<ll>> dp(N+1,vector<ll>(2,-INF)); | ^~~~ main.cpp:26:19: warning: integer overflow in expression of type 'long long int' results in '-9223372036854775808' [-Woverflow] 26 | if(dp[i][0] > -INF){ | ^~~~ main.cpp:30:19: warning: integer overflow in expression of type 'long long int' results in '-9223372036854775808' [-Woverflow] 30 | if(dp[i][1] > -INF){ | ^~~~
ソースコード
#include<bits/stdc++.h> #include<atcoder/all> #define chmin(x,y) (x) = min((x),(y)) #define chmax(x,y) (x) = max((x),(y)) using namespace std; using namespace atcoder; using ll = long long; const ll mod = 998244353; using mint = modint998244353; using Graph = vector<vector<int>>; const vector<int> dx = {1,0,-1,0}, dy = {0,1,0,-1}; int main(){ // input int N; cin >> N; vector<ll> A(N); for(int i = 0; i < N; i++) cin >> A[i]; // solve const ll INF = 1LL<<63; vector<vector<ll>> dp(N+1,vector<ll>(2,-INF)); dp[0][0] = 0; for(int i = 0; i < N; i++){ if(dp[i][0] > -INF){ chmax(dp[i+1][0],dp[i][0]); chmax(dp[i+1][1],dp[i][0] - A[i]); } if(dp[i][1] > -INF){ chmax(dp[i+1][1],dp[i][1]); chmax(dp[i+1][0],dp[i][1] + A[i]); } } // output cout << max(dp[N][0],dp[N][1]) << endl; }