Submission #927723

#TimeUsernameProblemLanguageResultExecution timeMemory
927723weakweakweakJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
215 ms19792 KiB
/* 5:05開始,也不算是virtual,因為我已經知道幾個人的分數了,也在去年資芽時聽過p4的題敘並想過。 所以就只是計時練習,應該會寫到19:05,然後等家長買晚餐回來吃後再把剩下的兩小時用一用,衝到div2就打div2 目標日本選訓!! */ #include <bits/stdc++.h> using namespace std; #define pii pair<int,int> #define fs first #define sc second pii nec[310000]; int a[310000], ans[310000]; int main () { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 0; i <= n; i++) { cin >> nec[i].fs; nec[i].sc = i; } sort (nec, nec + n + 1); for (int i = 0; i < n; i++) cin >> a[i]; sort (a, a + n); multiset<int>mst; for (int i = 0; i < n; i++) mst.insert(max(nec[i+1].fs - a[i], 0)); ans[nec[0].sc] = *mst.rbegin(); for (int i = 1; i <= n; i++) { auto it = mst.find( max(nec[i].fs - a[i-1], 0) ); if (it != mst.end()) mst.erase(it); mst.insert( max(nec[i-1].fs - a[i-1], 0) ); ans[nec[i].sc] = *mst.rbegin(); } for (int i = 0; i <= n; i++) cout << ans[i] << ' '; cout << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...