//君の手を握ってしまったら
//孤独を知らないこの街には
//もう二度と帰ってくることはできないのでしょう
//君が手を差し伸べた 光で影が生まれる
//歌って聞かせて この話の続き
//連れて行って見たことない星まで
//さユリ - 花の塔
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define starburst ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pii pair<int,int>
#define pb push_back
#define ff first
#define ss second
#define N 100005
struct inc{
int i, a, b;
};
void solve(){
int n, m; cin >> n >> m;
vector<inc> v(n);
vector<pii> ab(n);
vector<int> used(n, 0);
for(int i = 0; i < n; ++i){
v[i].i = i;
cin >> v[i].a;
ab[i].ff = v[i].a;
}
for(int i = 0; i < n; ++i) cin >> v[i].b, ab[i].ss = v[i].b;
sort(v.begin(), v.end(), [](inc a, inc b){return a.b < b.b;});
priority_queue<pii, vector<pii>, greater<pii>> pq;
if(m != 1) return;
for(int i = 0; i < n; ++i){
pq.push(pii(v[i].a, v[i].i));
}
int ans = pq.top().ff, j = 0;
while(pq.top().ff < ab[pq.top().ss].ss && !used[pq.top().ss]){
pii tmp = pq.top(); pq.pop();
if(used[tmp.ss]) {
ans = max(ab[tmp.ss].ss, ans);
break;
}
while(j != n && (used[j] || v[j].b <= tmp.ff)) ++j;
if(j == n) break;
used[tmp.ss] = 1;
}
cout << ans;
}
signed main(){
starburst
int t = 1; //cin >> t;
while(t--) solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
284 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
284 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |