답안 #246348

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
246348 2020-07-08T18:37:12 Z NONAME Unija (COCI17_unija) C++14
100 / 100
425 ms 31160 KB
#include  <bits/stdc++.h>
#define dbg(x) cerr << #x << " = " << x << "\n"
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie()
using namespace std;
using ll = long long;
using ld = long double;

bool cmp(pair <ll, ll> x, pair <ll, ll> y) {
    return (x.second == y.second) ? x.first > y.first : x.second > y.second;
}

int main() {
    fast_io;

    int n;
    vector <pair <ll, ll> > v;

    cin >> n;
    for (int i = 0; i < n; ++i) {
        ll x, y;
        cin >> x >> y;
        x /= 2, y /= 2;

        v.push_back(make_pair(x, y));
    }

    sort(v.begin(), v.end(), cmp);

    ll ans = 0, mx = 0;

    for (int i = 0; i < n; ++i) {
        ll x = v[i].first, y = v[i].second;

        ans += y * max(0ll, x - mx);

        mx = max(mx, x);
    }

    cout << ans * 4 << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 640 KB Output is correct
2 Correct 7 ms 640 KB Output is correct
3 Correct 6 ms 640 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 424 ms 31160 KB Output is correct
2 Correct 422 ms 31032 KB Output is correct
3 Correct 393 ms 31112 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 1408 KB Output is correct
2 Correct 20 ms 1344 KB Output is correct
3 Correct 14 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 3576 KB Output is correct
2 Correct 50 ms 3488 KB Output is correct
3 Correct 41 ms 3704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 119 ms 12432 KB Output is correct
2 Correct 124 ms 12432 KB Output is correct
3 Correct 117 ms 12360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 412 ms 31116 KB Output is correct
2 Correct 425 ms 31084 KB Output is correct
3 Correct 418 ms 31056 KB Output is correct