Submission #1114650

#TimeUsernameProblemLanguageResultExecution timeMemory
1114650AdamGSJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
94 ms13676 KiB
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n,k,odd,index; cin >> n; vector<pair<int,int>>dostepne_szyje,ciag; vector<int>jakie_maja_ludzie; vector<int>s(1),p(1); for(int i=0;i<n+1;++i){ cin >> k; dostepne_szyje.push_back({k,i+1}); } sort(dostepne_szyje.begin(),dostepne_szyje.end()); for(int i=0;i<n;++i){ cin >> k; jakie_maja_ludzie.push_back(k); } sort(jakie_maja_ludzie.begin(),jakie_maja_ludzie.end()); for(int i=0;i<n;++i){ p.push_back(max(p[i],max(dostepne_szyje[i].first-jakie_maja_ludzie[i],0))); } for(int i=n;i>0;--i){ s.push_back(max(s[n-i],max(dostepne_szyje[i].first-jakie_maja_ludzie[i-1],0))); //cout << s[n-i] << endl; } for(int i=0;i<p.size();++i){ //cout << p[i] << ' '; } //cout << endl; for(int i=0;i<s.size();++i){ //cout << s[i] << ' '; } //cout << endl; for(int i=0;i<n+1;++i){ ciag.push_back({dostepne_szyje[i].second,max(p[i],s[n-i])}); } sort(ciag.begin(),ciag.end()); for(int i=0;i<ciag.size();++i){ cout << ciag[i].second << ' '; } return 0; }

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:29:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     for(int i=0;i<p.size();++i){
      |                 ~^~~~~~~~~
ho_t1.cpp:33:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i=0;i<s.size();++i){
      |                 ~^~~~~~~~~
ho_t1.cpp:41:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for(int i=0;i<ciag.size();++i){
      |                 ~^~~~~~~~~~~~
ho_t1.cpp:6:13: warning: unused variable 'odd' [-Wunused-variable]
    6 |     int n,k,odd,index;
      |             ^~~
ho_t1.cpp:6:17: warning: unused variable 'index' [-Wunused-variable]
    6 |     int n,k,odd,index;
      |                 ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...