結果
問題 |
No.808 Kaiten Sushi?
|
ユーザー |
![]() |
提出日時 | 2019-03-22 22:41:25 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,715 bytes |
コンパイル時間 | 757 ms |
コンパイル使用メモリ | 88,496 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-19 06:06:27 |
合計ジャッジ時間 | 3,957 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 WA * 46 |
コンパイルメッセージ
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; | ^~~~
ソースコード
#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; rep(i,2*n){ if(sushi[si] < tea[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; }