結果
問題 | No.1199 お菓子配り-2 |
ユーザー |
|
提出日時 | 2020-08-28 22:55:12 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 435 ms / 1,000 ms |
コード長 | 876 bytes |
コンパイル時間 | 1,788 ms |
コンパイル使用メモリ | 171,328 KB |
実行使用メモリ | 11,520 KB |
最終ジャッジ日時 | 2024-11-14 03:43:21 |
合計ジャッジ時間 | 17,421 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 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<int64_t>>A(N,vector<int64_t>(M)); for(int i=0;i<N;i++){ for(int j=0;j<M;j++){ cin>>A[i][j]; } } vector<int64_t>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; }