Submission #689701

#TimeUsernameProblemLanguageResultExecution timeMemory
689701saayan007Arcade (NOI20_arcade)C++17
0 / 100
1 ms340 KiB
#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]; } ll order[m + 1]; fur(i, 1, m) { order[i] = i; } sort(order + 1, order + m + 1, [&](ll lt, ll rt) { return t[lt] < t[rt]; }); bool one = 1; fur(rep, 2, m) { ll i = order[rep]; ll j = order[rep - 1]; if(abs(t[i] - t[j]) < abs(a[i] - a[j])) { 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); s[0] = -1; fur(i, 0, m) { ll cur_l = -1; ll tim_l = 0; ll cur_r = -1; ll tim_r = 0; bool two = 1; fur(rep, 1, m) { ll j = order[rep]; 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...