結果

問題 No.674 n連勤
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2017-03-29 00:37:39
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,332 bytes
コンパイル時間 626 ms
コンパイル使用メモリ 83,888 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-10-12 13:14:32
合計ジャッジ時間 2,824 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 RE -
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 80 ms
4,356 KB
testcase_12 AC 78 ms
4,348 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

// テスト用

ll d[100100];

int main(){
	ll n,q;
	cin>>n>>q;
	clr(d,0);
	rep(i,0,q){
		ll a,b;
		cin>>a>>b;
		a++;b++;
		rep(j,a,b+1)d[j]=1;
		int index1 = 0;
		int index2 = 1;
		ll mx = 0;
		while(1){
			if(index1>n+10)break;
			if(index2>n+10)break;
			int flag1 = 0;
			int flag2 = 0;
			if(d[index1]==0&&d[index1+1]==1){
				flag1 = 1;
			}
			else{
				index1++;
			}
			if(d[index2-1]==1&&d[index2]==0){
				flag2 = 1;
			}
			else{
				index2++;
			}
			if(flag1==1&&flag2==1){
				mx = max(mx,index2-index1-1LL);
				index1 = index2;
				index2 = index1 + 1;
			}	
		}
		printf("%lld\n", mx);
	}
	return 0;
}
0