結果

問題 No.607 開通777年記念
ユーザー newlife171128newlife171128
提出日時 2017-12-20 22:10:35
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 178 ms / 2,000 ms
コード長 1,527 bytes
コンパイル時間 496 ms
コンパイル使用メモリ 63,056 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-09 16:43:03
合計ジャッジ時間 1,715 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 11 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 3 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 171 ms
5,376 KB
testcase_12 AC 178 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>

using namespace std;

int main() {

	int n = 0;
	int m = 0;
	cin >> n >> m;

	int car[n];
	int car_t[n + 1];

	for(int i=0; i<n; i++){
		car[i] =0;
	}
/*	for(int i=0; i<n+1; i++){
		car_t[i] =0;
	}*/

	int tmp = 0;

	bool judge = false;

	int left =0;
	int right =0;
	int ans=0;

	for (int i = 0; i < m; i++) {
		ans =0;
		left =0;
		if(judge){
			break;
		}
		for (int i = 0; i < n; i++) {
			cin >> tmp;
			car[i] += tmp;
		}

		for(right=0; right<n; right++ ){
			ans += car[right];

			if(ans == 777){
				judge = true;
			}else if (ans >777) {

				while(ans>777){
					ans -= car[left];
					left++;
				}
				if(ans == 777){
						judge = true;
				}

			}
		}

/*		for (int i = 0; i < n; i++) {
			car_t[i + 1] = car_t[i] + car[i];

				cout<<car_t[i+1]<<endl;
		}*/

		stringstream ss;

		string fever;

/*		for (int t = 1; t <= n; t++) {

			int ans = car_t[t] - car_t[0];

			ss << ans;
			fever = ss.str();

			if(fever == "777"){
				judge =true;
			}
			ss.str("");
			ss.clear(stringstream::goodbit);
				cout<<"t:"<<t<<" "<<ans<<endl;
			int tmp = 0;
			for (int k = 0; k < n - t; k++) {
				tmp = car_t[k + 1 + t] - car_t[k + 1];

				ss << tmp;
				fever = ss.str();

				if(fever == "777"){
					judge =true;
				}
				ss.str("");
				ss.clear(stringstream::goodbit);
							cout<<"t:"<<t<<" "<<tmp<<endl;
			}
		}*/
	}


	if (judge) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}
0