Submission #307873

#TimeUsernameProblemLanguageResultExecution timeMemory
307873Bill_00Just Long Neckties (JOI20_ho_t1)C++14
100 / 100
421 ms12700 KiB
#include <bits/stdc++.h> #define pp push #define mp make_pair #define ff first #define ss second #define pb push_back using namespace std; pair<int,int>p[200005]; pair<int,int>h[200005]; int dpf[200005]; int dpl[200005]; vector<pair<int,int> >v; int main(){ int n; cin >> n; for(int i=1;i<=n+1;i++){ int a; cin >> a; p[i]=mp(a,i); } for(int i=1;i<=n;i++){ int a; cin >> a; h[i]=mp(a,i); } sort(p+1,p+n+2); sort(h+1,h+n+1); dpf[0]=0; for(int i=1;i<=n;i++){ int a=p[i].ff; int b=h[i].ff; dpf[i]=max(dpf[i-1],a-b); } dpl[n+1]=0; for(int i=n;i>=1;i--){ int a=p[i+1].ff; int b=h[i].ff; dpl[i]=max(dpl[i+1],a-b); } for(int i=1;i<=n+1;i++){ v.pb(mp(p[i].ss,max(dpf[i-1],dpl[i]))); } sort(v.begin(),v.end()); for(int i=0;i<v.size();i++){ cout << v[i].ss << ' '; } }

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:44:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |  for(int i=0;i<v.size();i++){
      |              ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...