結果
| 問題 |
No.808 Kaiten Sushi?
|
| コンテスト | |
| ユーザー |
milanis48663220
|
| 提出日時 | 2020-06-07 00:41:26 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,224 bytes |
| コンパイル時間 | 1,006 ms |
| コンパイル使用メモリ | 89,164 KB |
| 実行使用メモリ | 14,464 KB |
| 最終ジャッジ日時 | 2024-12-23 14:31:13 |
| 合計ジャッジ時間 | 7,117 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 WA * 15 |
ソースコード
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
ll N, L;
ll x[100000];
ll y [100000];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << setprecision(10) << fixed;
ll cur = 0;
ll ans = 0;
set<ll> stx, sty;
cin >> N >> L;
for(int i = 0; i < N; i++){
cin >> x[i]; stx.insert(x[i]);
}
for(int i = 0; i < N; i++){
cin >> y[i]; sty.insert(y[i]);
}
for(int i = 0; i < N; i++){
// sushi
auto p = sty.upper_bound(cur);
if(p == sty.end()){
p = sty.upper_bound(0);
}
auto q = stx.upper_bound(*p);
if(q == stx.begin()){
q = stx.end();
}
q--;
ans += (*q-cur+L)%L;
cur = *q;
stx.erase(*q);
// tea
p = stx.upper_bound(cur);
if(p == stx.end()){
p = stx.upper_bound(0);
}
q = sty.upper_bound(*p);
if(q == sty.begin()){
q = sty.end();
}
q--;
ans += (*q-cur+L)%L;
cur = *q;
sty.erase(*q);
}
cout << ans << endl;
}
milanis48663220