# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
246090 | VEGAnn | Unija (COCI17_unija) | C++14 | 451 ms | 13560 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |