Submission #440057

#TimeUsernameProblemLanguageResultExecution timeMemory
440057gromperenUnija (COCI17_unija)C++14
100 / 100
361 ms32564 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<ll,ll>> 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()); ll 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<long long int, long long 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<long long int, long long 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...