結果
問題 | No.607 開通777年記念 |
ユーザー |
![]() |
提出日時 | 2017-12-07 12:17:59 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 71 ms / 2,000 ms |
コード長 | 995 bytes |
コンパイル時間 | 1,755 ms |
コンパイル使用メモリ | 167,752 KB |
実行使用メモリ | 11,332 KB |
最終ジャッジ日時 | 2024-11-29 04:54:55 |
合計ジャッジ時間 | 2,503 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
ソースコード
#include<bits/stdc++.h> #define ll long long #define fi first #define se second #define show(x) cout<<#x<<"="<<x<<"\n" using namespace std; int n,m; ll a[1001][1001]; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.precision(10); cout<<fixed; #ifdef LOCAL_DEFINE freopen("in", "r", stdin); freopen("out","w",stdout); #endif cin>>n>>m; for(int i=0;i<m;i++){ for(int j=0;j<n;j++){ cin>>a[i][j]; if(i!=0)a[i][j]+=a[i-1][j]; } } for(int i=0;i<m;i++){ int r=0,l=0; ll sum=0; while(r<n){ //show(sum); if(sum==777){ cout<<"YES"<<"\n"; return 0; } if(sum+a[i][r]<=777){ sum+=a[i][r]; r++; }else{ while(sum+a[i][r]>777){ if(r==l){ break; } sum-=a[i][l]; l++; } sum+=a[i][r]; r++; } } if(sum==777){ cout<<"YES"<<"\n"; return 0; } } cout<<"NO"<<"\n"; #ifdef LOCAL_DEFINE cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; #endif return 0; }