Submission #575156

#TimeUsernameProblemLanguageResultExecution timeMemory
575156vaavenJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
398 ms21732 KiB
#include <iostream> #include <vector> #include <algorithm> #include <iomanip> #include <tuple> #include <math.h> #include <set> #include <stack> #include <bitset> #include <map> #include <queue> #include <random> #include <array> #include <unordered_set> #include <cmath> #include <cassert> #include <unordered_map> #define DEBUG #define pqueue priority_queue #define pb(x) push_back(x) //#define endl '\n' #define all(x) x.begin(), x.end() #define int long long #define mk(a, b) make_pair(a, b) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef vector<int> vi; typedef vector<vector<int> > vvi; typedef vector<ull> vull; typedef vector<ll> vll; // typedef tuple<ll, ll, ll> tiii; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef pair<ll, ll> pll; typedef vector<bool> vb; typedef vector<string> vs; typedef vector<vector<int> > vvi; typedef vector<char> vc; const ll inf = 3e9 + 228; const ll infll = 1e18 + 228; const ll mod = 1e9 + 7; const ll mod3 = 1e9 + 7; //static const int maxn = 1e6 + 228; const ld eps = 1e-6; const ll mod2 = 998244353; const ld PI = atan2l(0, -1); void fast_io() { // ios_base::sync_with_stdio(0); // cin.tie(0); // cout.tie(0); // freopen("main.in", "r", stdin); // freopen("lumber.out", "w", stdout); } void solve() { int n; cin >> n; vpii a(n + 1); vi b(n); for(int i=0; i<n+1; i++){ cin >> a[i].first; a[i].second = i; } for(int &i:b) cin >> i; sort(all(a)); sort(all(b)); multiset<int> kek; for(int i=0; i<n; i++){ kek.insert(b[i] - a[i + 1].first); } vi ans(n + 1); ans[a[0].second] = *(kek.begin()); for(int i=0; i<n; i++){ kek.erase(kek.find(b[i] - a[i + 1].first)); kek.insert(b[i] - a[i].first); ans[a[i + 1].second] = *(kek.begin()); } for(int i:ans) cout << max(-i, 0ll) << " "; cout << endl; } /* 3 4 3 7 6 2 6 4 */ signed main() { srand(time(NULL)); fast_io(); int q = 1; // cin >> q; while (q--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...