結果
問題 |
No.1199 お菓子配り-2
|
ユーザー |
|
提出日時 | 2020-08-28 22:52:45 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 861 bytes |
コンパイル時間 | 1,631 ms |
コンパイル使用メモリ | 171,612 KB |
実行使用メモリ | 7,552 KB |
最終ジャッジ日時 | 2024-11-14 03:42:52 |
合計ジャッジ時間 | 5,837 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 |
other | WA * 45 |
ソースコード
#include <bits/stdc++.h> using namespace std; #include <math.h> #include <iomanip> template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const int mod=1000000007; const int INF=1001001001; int main() { int N,M; cin>>N>>M; vector<vector<int>>A(N,vector<int>(M)); for(int i=0;i<N;i++){ for(int j=0;j<M;j++){ cin>>A[i][j]; } } vector<int>t(N); for(int i=0;i<N;i++){ int64_t sum=0; for(int j=0;j<M;j++){ sum+=A[i][j]; } t[i]=sum; } int64_t ans=0; int cnt=1; for(int i=0;i<N;i++){ if((cnt)%2!=0){ if(t[i+1]<t[i]){ans+=t[i];cnt++;} } else{ if(i==N-1){continue;} else if(t[i+1]>t[i]){ans-=t[i];cnt++;} } } cout<<ans<<endl; return 0; }