Submission #476944

#TimeUsernameProblemLanguageResultExecution timeMemory
476944dsyzJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
387 ms34148 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define MAXN (1000005) int main() { ios_base::sync_with_stdio(false);cin.tie(0); ll N; ll sum = 0; ll maximum = 0; cin>>N; pair<ll,ll> A[N + 1]; ll z[N + 1]; ll B[N]; vector<pair<ll,ll>> v; for(ll i = 0;i < (N + 1);i++){ ll a; cin>>a; z[i] = a; A[i].first = a; A[i].second = i; } for(ll i = 0;i < N;i++){ cin>>B[i]; } sort(A,A + (N + 1)); sort(B,B + N); multiset<ll> s; for(ll i = 1;i < (N + 1);i++){ s.insert(max(A[i].first - B[i - 1],0ll)); } for(ll i = 0;i < (N + 1);i++){ if(i == 0){ v.push_back(make_pair(A[i].second,*prev(s.end()))); }else if(i == N){ s.erase(s.find(max(A[i].first - B[i - 1],0ll))); s.insert(max(A[i - 1].first - B[i - 1],0ll)); v.push_back(make_pair(A[i].second,*prev(s.end()))); }else{ s.erase(s.find(max(A[i].first - B[i - 1],0ll))); s.insert(max(A[i - 1].first - B[i - 1],0ll)); v.push_back(make_pair(A[i].second,*prev(s.end()))); s.insert(max(A[i].first - B[i],0ll)); } } sort(v.begin(),v.end()); for(ll i = 0;i < v.size();i++){ cout<<v[i].second<<" "; } cout<<'\n'; }

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:47:18: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |   for(ll i = 0;i < v.size();i++){
      |                ~~^~~~~~~~~~
ho_t1.cpp:8:6: warning: unused variable 'sum' [-Wunused-variable]
    8 |   ll sum = 0;
      |      ^~~
ho_t1.cpp:9:6: warning: unused variable 'maximum' [-Wunused-variable]
    9 |   ll maximum = 0;
      |      ^~~~~~~
ho_t1.cpp:12:6: warning: variable 'z' set but not used [-Wunused-but-set-variable]
   12 |   ll z[N + 1];
      |      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...