Submission #519699

#TimeUsernameProblemLanguageResultExecution timeMemory
519699ac2huArcade (NOI20_arcade)C++14
7 / 100
1 ms332 KiB
#include <bits/stdc++.h> using namespace std; const int N = 5e5 + 10; struct mov{ int t,loc; } a[N]; int n,m; signed main(){ iostream::sync_with_stdio(false); cin.tie(nullptr);cout.tie(nullptr); cin >> n >> m; vector<pair<int,int>> a(m); for(int i = 0;i<m;i++){ cin >> a[i].first; } for(int i =0 ;i<m;i++){ cin >> a[i].second; } sort(a.begin(),a.end(),[&](pair<int,int> a,pair<int,int> b){ return a.first < b.first||(a.first == b.first && a.second > b.second); }); a.erase(unique(a.begin(),a.end()), a.end()); m = a.size(); // int idxx[m]; // for(int i = 0;i<m;i++) // cout << a[i].first << " "; // cout << "\n"; // for(int i = 0;i<m;i++) // cout << a[i].second << " "; // cout << "\n"; vector<int> arms; for(int i = 0;i<m;i++){ int idx = -1; int mn = 1e9; for(int j = 0;j<(int)arms.size();j++){ int e = arms[j]; if(abs(a[e].second - a[i].second) <= abs(a[e].first - a[i].first)){ int tm = abs(a[i].second - a[e].second); if(mn > tm){ idx = j; mn = tm; } } } if(idx == -1){ arms.push_back(i); // idxx[i] = arms.size() - 1; } else{ arms[idx] = i; // idxx[i] = idx; } } // for(int i = 0;i<m;i++) // cout << idxx[i] << " "; // cout << "\n"; cout << arms.size() << "\n"; }
#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...