Submission #1114641

#TimeUsernameProblemLanguageResultExecution timeMemory
1114641AdamGSJust Long Neckties (JOI20_ho_t1)C++17
100 / 100
297 ms17992 KiB
#include<bits/stdc++.h> using namespace std; using i64 = int64_t; int main() { //ios_base::sync_with_stdio(0); //cin.tie(0); i64 N; cin >> N; vector<pair<i64, i64>> tie(N + 1); for (i64 i = 0; i <= N; i++) { cin >> tie[i].first; tie[i].second = i; } sort(tie.begin(), tie.end()); vector<i64> emp(N); for (i64 i = 0; i < N; i++) { cin >> emp[i]; } sort(emp.begin(), emp.end()); multiset<i64> akt; vector<i64> wynik(N + 1); for (i64 i = 1; i <= N; i++) { akt.insert(max(tie[i].first - emp[i - 1], (i64)0)); } auto it = akt.end(); it--; wynik[tie[0].second] = *it; for (i64 i = 1; i <= N; i++) { auto it = akt.find(max((i64)0, tie[i].first - emp[i - 1])); akt.erase(it); akt.insert(max((i64)0, tie[i - 1].first - emp[i - 1])); auto it2 = akt.end(); it2--; wynik[tie[i].second] = *it2; } for (i64 i = 0; i < wynik.size(); i++) { cout << wynik[i] << ' '; } cout << "\n"; return 0; }

Compilation message (stderr)

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