結果

問題 No.808 Kaiten Sushi?
ユーザー Jiro_tech15Jiro_tech15
提出日時 2019-03-22 22:46:01
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,935 bytes
コンパイル時間 734 ms
コンパイル使用メモリ 88,396 KB
実行使用メモリ 4,636 KB
最終ジャッジ日時 2023-10-19 09:57:30
合計ジャッジ時間 10,991 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 2 ms
4,348 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 3 ms
4,348 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 33 ms
4,348 KB
testcase_24 AC 28 ms
4,348 KB
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 RE -
testcase_49 RE -
testcase_50 RE -
testcase_51 RE -
testcase_52 RE -
testcase_53 RE -
testcase_54 AC 2 ms
4,348 KB
testcase_55 AC 1 ms
4,348 KB
testcase_56 RE -
testcase_57 AC 25 ms
4,348 KB
testcase_58 AC 45 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:70:33: warning: ‘ansp’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   70 |                 cout<<l*(ans-1)+ansp<<endl;
      |                                 ^~~~

ソースコード

diff #

#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)

//struct position{int x;};

int main(void){
	int n,x,y;
	ll l;
	cin>>n>>l;
	//vector<position> P;
	vector<int> sushi,tea;
	rep(i,n){
		cin>>x;
		sushi.push_back(x);
	}
	rep(i,n){
		cin>>y;
		tea.push_back(y);
	}
	sushi.push_back(1000000009);
	tea.push_back(1000000009);
	vector<int> atode;
	int sc=0,tc=0;
	int count=0,ans=0,ansp;
	int si=0,ti=0;
	while(si<n||ti<n){
		if(sushi[si] < tea[ti]){
			sc++;
			si++;
		}else{
			if(sc > 0){
				if(ans <= sc){
					ans = sc;

					ansp = tea[ti];

				}
				sc--;
			}else{
				atode.push_back(ti%n);
			}
			ti++;
		}

		//cout<<sc<<" "<<tc<<" "<<atode.size()<<" "<<ans<<endl;
	}


	
	if(atode.size() == 0){
		cout<<l*(ans-1)+ansp<<endl;
		return 0;
	}
	ti = (atode[atode.size()-1])%n;
	
	while(sushi[si]<tea[ti]){
		si = (si+1)%n;
	}
	ti=(ti+1)%n;
	sc = 0;
	tc = 0;
	vector<int> sushi2,tea2;
	rep(i,n){
		if(i<si){
			sushi2[si] = l + sushi[si];
		}else{
			sushi2[si] = sushi[si];
		}
		
	}
	rep(i,n){
		if(i<ti){
			tea2[ti] = l + tea[ti];
		}else{
			tea2[ti] = tea[ti];
		}
		
	}
	rep(i,2*n){
		if(sushi2[si] < tea2[ti]){
			sc++;
			si = (si+1)%n;
		}else{
			if(sc > 0){
				if(ans <= sc){
					ans = sc;
					if(ansp > tea[ti]){
						ansp = tea[ti];
					}
					
				}
				sc--;
			}else{
				
			}
			ti=(ti+1)%n;
		}
		//cout<<sc<<" "<<tc<<" "<<atode.size()<<" "<<ans<<endl;
	}
	cout<<l*ans+ansp<<endl;
	
	

	return 0;
}
0