답안 #62948

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
62948 2018-07-31T03:29:53 Z win11905 Unija (COCI17_unija) C++11
100 / 100
656 ms 58328 KB
#include <bits/stdc++.h>
using namespace std;

#define long long long
#define pii pair<int, int>
#define x first
#define y second

int n;
vector<pii> V, A;

int main() {
    scanf("%d", &n); 
    V.reserve(n+1), A.reserve(n+1);
    for(int i = 0, a, b; i < n; ++i) {
        scanf("%d %d", &a, &b);
        V.emplace_back(a >> 1, b >> 1);
    }
    sort(V.begin(), V.end(), [&](const pii &a, const pii &b) {
        if(a.x == b.x) return a.y < b.y;
        return a.x > b.x;
    });
    A.emplace_back(V[0]);
    for(int i = 1; i < n; ++i) {
        if(V[i].y > A.back().y) A.emplace_back(V[i]);
    }
    int pv = 0;
    long sum = 0;
    for(auto x : A) {
        sum += 1ll * x.x * (x.y - pv);
        pv = x.y;
    }
    printf("%lld\n", sum << 2);
}

Compilation message

unija.cpp: In function 'int main()':
unija.cpp:13:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n); 
     ~~~~~^~~~~~~~~~
unija.cpp:16:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d", &a, &b);
         ~~~~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 492 KB Output is correct
3 Correct 2 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 492 KB Output is correct
2 Correct 3 ms 492 KB Output is correct
3 Correct 4 ms 508 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 560 KB Output is correct
2 Correct 3 ms 576 KB Output is correct
3 Correct 3 ms 712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 744 KB Output is correct
2 Correct 5 ms 744 KB Output is correct
3 Correct 6 ms 864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 561 ms 22528 KB Output is correct
2 Correct 497 ms 22540 KB Output is correct
3 Correct 428 ms 22540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 22540 KB Output is correct
2 Correct 2 ms 22540 KB Output is correct
3 Correct 3 ms 22540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 22540 KB Output is correct
2 Correct 16 ms 22540 KB Output is correct
3 Correct 15 ms 22540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 48 ms 22540 KB Output is correct
2 Correct 40 ms 22540 KB Output is correct
3 Correct 51 ms 22540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 134 ms 22540 KB Output is correct
2 Correct 131 ms 22540 KB Output is correct
3 Correct 140 ms 22748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 485 ms 28180 KB Output is correct
2 Correct 562 ms 43304 KB Output is correct
3 Correct 656 ms 58328 KB Output is correct