Submission #566993

#TimeUsernameProblemLanguageResultExecution timeMemory
566993almothana05Just Long Neckties (JOI20_ho_t1)C++14
100 / 100
240 ms9328 KiB
#include<bits/stdc++.h> #define mod 1000000007 #define inf 100000000000000000 using namespace std; vector<int>num; vector<pair<int , int> >cmp , erg; int suf[300001]; int main(){ // ios_base::sync_with_stdio(false); // cin.tie(NULL); int menge, numm , nummer; cin >> menge; for(int i = 0 ; i < menge + 1; i++){ cin >> numm; cmp.push_back({numm , i}); } for(int i = 0 ; i < menge ; i++){ cin >> numm; num.push_back(numm); } sort(num.begin() , num.end()); sort(cmp.begin() , cmp.end()); for(int i = menge - 1 ; i >= 0 ; i--){ // cout << cmp[i + 1] << ' ' << num[i] << "\n"; suf[i] = max(suf[i + 1] , max(0 , cmp[i + 1].first - num[i])); } // return 0; int pref = 0; for(int i = 0 ; i < menge + 1; i++){ if(i == 0){ erg.push_back({cmp[i].second , max(suf[i] , pref)}); continue; } pref = max(pref , max(0 , cmp[i - 1].first - num[i - 1])); erg.push_back({cmp[i].second , max(suf[i] , pref)}); // cout << } sort(erg.begin() , erg.end()); for(int i = 0 ; i < erg.size() ; i++){ cout << erg[i].second << " "; } cout << "\n"; }

Compilation message (stderr)

ho_t1.cpp: In function 'int main()':
ho_t1.cpp:39:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |    for(int i = 0 ; i < erg.size() ; i++){
      |                    ~~^~~~~~~~~~~~
ho_t1.cpp:11:23: warning: unused variable 'nummer' [-Wunused-variable]
   11 |    int menge,  numm , nummer;
      |                       ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...