Submission #440056

#TimeUsernameProblemLanguageResultExecution timeMemory
440056gromperenUnija (COCI17_unija)C++14
60 / 100
372 ms31464 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int main(){ ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<pair<int,int>> v(n), a; ll ans = 0; for (int i = 0; i < n; ++i) cin >> v[i].first >> v[i].second; sort(v.begin(), v.end()); reverse(v.begin(), v.end()); int prev = 0, prevy = 0; for (int i = 0; i < n; ++i) { if (v[i].first == prev ) continue; if (v[i].second <= prevy) continue; a.push_back(v[i]); prev = v[i].first; prevy = v[i].second; } for (int i = 0; i < a.size(); ++i) { ans += a[i].second * (a[i].first - ((i < a.size() - 1) ? a[i+1].first : 0)); } cout << ans << "\n"; return 0; }

Compilation message (stderr)

unija.cpp: In function 'int main()':
unija.cpp:25:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for (int i = 0; i < a.size(); ++i) {
      |                  ~~^~~~~~~~~~
unija.cpp:26:42: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |   ans += a[i].second * (a[i].first - ((i < a.size() - 1) ? a[i+1].first : 0));
      |                                        ~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...