#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define SZ(x) ((int)((x).size()))
#define pow2(x) ((ll)(x) * (x))
const ll mod = 1e9 + 7;
const int INF = 1e9 + 5; // 998244353
const ll INFF = 1e18 + 5;
// Super is the cutest girl
void solve()
{
ll n, m;
cin >> n >> m;
vl a(n), b(n);
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
ll cnt = 0;
for (int i = 0; i < n; i++)
{
cin >> b[i];
if (b[i] > a[i])
{
cnt++;
}
}
ll ans = INFF;
if (cnt % 2 == 0)
{
for (int i = 0; i < n; i++)
{
ans = min(ans, max(a[i], b[i]));
}
}
else
{
int maxpos = 0;
ll maxcurr = 0;
for (int i = 0; i < n; i++)
{
if (a[i] < b[i])
{
if (a[i] > maxcurr)
{
maxcurr = a[i];
maxpos = i;
}
}
else
{
if (b[i] > maxcurr)
{
maxcurr = a[i];
maxpos = i;
}
}
}
for (int i = 0; i < n; i++)
{
if (i == maxpos)
{
ans = min(ans, a[i]);
}
else
ans = min(ans, max(a[i], b[i]));
}
}
// subtask 1
cout << ans << '\n';
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// int t; cin >> t; while(t--)
solve();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |