Submission #246090

#TimeUsernameProblemLanguageResultExecution timeMemory
246090VEGAnnUnija (COCI17_unija)C++14
100 / 100
451 ms13560 KiB
#include <bits/stdc++.h> #define PB push_back #define sz(x) ((int)x.size()) #define all(x) x.begin(),x.end() using namespace std; typedef long long ll; typedef long double ld; const int oo = 2e9; const int N = 1000100; const int md = 998244353; const int PW = 233; const int B = 700; int n, a[N], b[N], nm[N]; ll ans = 0; bool cmp(int _x, int _y){ if (a[_x] == a[_y]) return b[_x] < b[_y]; else return a[_x] > a[_y]; } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); #ifdef _LOCAL freopen("in.txt","r",stdin); #endif // _LOCAl cin >> n; for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; a[i] /= 2; b[i] /= 2; nm[i] = i; } sort(nm, nm + n, cmp); int la = oo, lb = 0; for (int it = 0; it < n; it++){ int i = nm[it]; if (lb >= b[i]) continue; ans += (ll(b[i]) - ll(lb)) * ll(a[i]); lb = b[i]; la = a[i]; } cout << ans * 4; return 0; }

Compilation message (stderr)

unija.cpp: In function 'int main()':
unija.cpp:41:9: warning: variable 'la' set but not used [-Wunused-but-set-variable]
     int la = oo, lb = 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...