結果

問題 No.808 Kaiten Sushi?
ユーザー Jiro_tech15Jiro_tech15
提出日時 2019-03-22 23:48:41
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,022 bytes
コンパイル時間 846 ms
コンパイル使用メモリ 91,204 KB
実行使用メモリ 6,752 KB
最終ジャッジ日時 2023-10-19 10:58:10
合計ジャッジ時間 11,176 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
4,348 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
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 32 ms
4,348 KB
testcase_24 AC 26 ms
4,348 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 2 ms
4,348 KB
testcase_55 AC 2 ms
4,348 KB
testcase_56 WA -
testcase_57 AC 25 ms
4,348 KB
testcase_58 AC 44 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;
	si = 0;
	while(sushi[si]<tea[ti]){
		si = (si+1)%n;
	}
	ti=(ti+1)%n;
	sc = 0;
	tc = 0;
	vector<ll> sushi2,tea2;
	cout<<"hogea"<<si<<" "<<ti<<endl;
	rep(i,n){
		if(i<si%n){
			sushi2.push_back(l + sushi[si]);
		}else{
			sushi2.push_back(sushi[si]);
		}
		
	}
	rep(i,n){
		if(i<ti%n){
			tea2.push_back(l + tea[ti]);
		}else{
			tea2.push_back(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 > tea2[ti]){
						ansp = tea2[ti];
					}
					
				}
				sc--;
			}else{
				
			}
			ti=(ti+1)%n;
		}
		cout<<sc<<" "<<tc<<" "<<atode.size()<<" "<<ans<<" "<<si<<" "<<ti<<endl;
	}
	cout<<l*(ans-1)+ansp<<endl;
	
	

	return 0;
}
0