Submission #1115365

#TimeUsernameProblemLanguageResultExecution timeMemory
1115365staszic_ojuzArt Exhibition (JOI18_art)C++17
100 / 100
607 ms66468 KiB
#include<bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(0); cin.tie(0); long long n, wiel, wart, l = 0, p = 0, overall = 0; cin >> n; map<long long, long long> m; vector<vector<long long>> v; for (int i = 0; i < n; i++) { cin >> wiel >> wart; m[wiel] += wart; overall += wart; } for (auto [wie, war] : m) { v.push_back({wie, war}); } long long wyn = 0, suma = v[0][1], osw = v[v.size() - 1][0], i = 0; while (l < v.size()) { if (i < v.size()) { if (overall - osw + v[i][0] > wyn) { wyn = overall - osw + v[i][0]; } if (v[i][1] > wyn) { wyn = v[i][1]; } overall -= v[i][1]; } i += 1; if ((l >= p) || (p < v.size() && suma - v[p][0] + v[l][0] > v[p][1])) { if (suma - v[p][0] + v[l][0] > wyn) { wyn = suma - v[p][0] + v[l][0]; } p += 1; if (p < v.size() - 1) { suma += v[p][1]; } } else { suma -= v[l][1]; l += 1; } } cout << wyn; }

Compilation message (stderr)

art.cpp: In function 'int main()':
art.cpp:19:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     while (l < v.size()) {
      |            ~~^~~~~~~~~~
art.cpp:20:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |         if (i < v.size()) {
      |             ~~^~~~~~~~~~
art.cpp:30:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |         if ((l >= p) || (p < v.size() && suma - v[p][0] + v[l][0] > v[p][1])) {
      |                          ~~^~~~~~~~~~
art.cpp:35:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |             if (p < v.size() - 1) {
      |                 ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...