이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using pl = pair<long long, long long>;
using vi = vector<int>;
using vl = vector<long long>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<long long, long long>>;
#define fur(i, a, b) for(ll i = a; i <= (ll)b; ++i)
#define ruf(i, a, b) for(ll i = a; i >= (ll)b; --i)
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define nl "\n"
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const ll mxm = 5e5L;
ll n, m;
ll t[mxm];
ll a[mxm];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
fur(i, 1, m) {
cin >> t[i];
}
fur(i, 1, m) {
cin >> a[i];
}
bool one = 1;
fur(i, 2, m) {
if(abs(t[i] - t[i - 1]) < abs(a[i] - a[i - 1])) {
one = 0;
}
}
if(one) {
cout << 1 << nl;
return 0;
}
ll s[m + 1];
fur(i, 1, m) {
s[i] = a[i];
}
sort(s + 1, s + m + 1);
fur(i, 1, m) {
ll cur_l = -1;
ll tim_l = 0;
ll cur_r = -1;
ll tim_r = 0;
bool two = 1;
fur(j, 1, m) {
if(a[j] <= s[i]) { // left hand
if(cur_l == -1) {
cur_l = a[j];
tim_l = t[j];
}
else if(abs(t[j] - tim_l) < abs(a[j] - cur_l) ) {
two = 0;
break;
} else {
cur_l = a[j];
tim_l = t[j];
}
}
else { // right hand
if(cur_r == -1) {
cur_r = a[j];
tim_r = t[j];
}
else if(abs(t[j] - tim_r) < abs(a[j] - cur_r) ) {
two = 0;
break;
} else {
cur_r = a[j];
tim_r = t[j];
}
}
}
if(two) {
cout << 2 << nl;
return 0;
}
}
cout << 3 << nl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |