結果

問題 No.607 開通777年記念
ユーザー syake_tasyake_ta
提出日時 2018-08-30 22:48:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 221 ms / 2,000 ms
コード長 818 bytes
コンパイル時間 2,487 ms
コンパイル使用メモリ 63,124 KB
実行使用メモリ 7,268 KB
最終ジャッジ日時 2023-10-11 21:46:46
合計ジャッジ時間 2,415 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,352 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 40 ms
5,308 KB
testcase_08 AC 1 ms
4,356 KB
testcase_09 AC 4 ms
4,348 KB
testcase_10 AC 5 ms
4,348 KB
testcase_11 AC 221 ms
7,268 KB
testcase_12 AC 205 ms
7,116 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int INF = (int)1e9 + 1;

int n, m, a[1001][1001] = {};

int main(void) {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		for(int j = 0; j < n; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 1; i < m; i++) {
		for (int j = 0; j < n; j++) {
			a[i][j] += a[i - 1][j];
		}
	}
	for (int i = 0; i < m; i++) {
		for (int j = 1; j < n; j++) {
			a[i][j] += a[i][j - 1];
		}
	}

	string ans = "NO";

	for (int i = 0; i < m; i++) {
		for (int j = 0; j < n; j++) {
			int d = a[i][j] - 777;
			if (d < 0) continue;
			if (d == 0) ans = "YES";
			int k = lower_bound(a[i], a[i] + j, d) - a[i];
			if (k != j) if (a[i][j] - a[i][k] == 777) ans = "YES";
		}
	}
	cout << ans << '\n';
	return 0;
}
0