Submission #314274

#TimeUsernameProblemLanguageResultExecution timeMemory
314274BeanZJust Long Neckties (JOI20_ho_t1)C++14
100 / 100
370 ms18936 KiB
// I_Love_LPL #include <bits/stdc++.h> using namespace std; #define ll long long #define endl '\n' const int N = 2e5 + 5; pair<ll, ll> a[N]; ll b[N], ans[N]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); if (fopen("A.inp", "r")){ freopen("test.inp", "r", stdin); freopen("test.out", "w", stdout); } ll n; cin >> n; for (int i = 1; i <= (n + 1); i++) cin >> a[i].first, a[i].second = i; sort(a + 1, a + n + 1 + 1); for (int i = 1; i <= n; i++) cin >> b[i]; sort(b + 1, b + n + 1); multiset<ll, greater<ll>> s; for (int i = 2; i <= (n + 1); i++){ s.insert(max(a[i].first - b[i - 1], 0ll)); } ans[a[1].second] = *s.begin(); for (int i = 2; i <= (n + 1); i++){ s.erase(s.find(max(a[i].first - b[i - 1], 0ll))); s.insert(max(a[i - 1].first - b[i - 1], 0ll)); ans[a[i].second] = *s.begin(); } for (int i = 1; i <= (n + 1); i++){ cout << ans[i] << " "; } } /* */

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:13:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   13 |         freopen("test.inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
ho_t1.cpp:14:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   14 |         freopen("test.out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...