답안 #542035

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
542035 2022-03-25T08:08:28 Z AJ00 Unija (COCI17_unija) C++14
100 / 100
285 ms 31044 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
pair<int,int> rect[1000001]; 
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t=1,n,curx,cury; 
    //cin >> t; 
    while (t--){
        cin >> n;
        for (int i = 0; i < n; i++){
            cin >> rect[i].first >> rect[i].second;
            rect[i].first /= 2;
            rect[i].second /= 2;
        }    
        rect[n] = {0,0};
        sort(rect,rect+n+1,greater<pair<int,int>>());
        curx = rect[0].first;
        cury = rect[0].second;
       // cout << rect[0].first << " " << rect[0].second << "\n";
        int  i = 1,ans=0;
        while(i<=n){
            while(cury >= rect[i].second && i<n){
               // cout << rect[i].first << " " << rect[i].second << "\n";
                i++;
            }
            ans += ((curx-rect[i].first)*cury);
            curx = rect[i].first;
            cury = rect[i].second;
           // cout << rect[i].first << " " << rect[i].second << " " << ans << "\n";
            i++;
        }
        ans *= 4;
        cout << ans << "\n";
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 396 KB Output is correct
2 Correct 2 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 278 ms 31044 KB Output is correct
2 Correct 285 ms 30972 KB Output is correct
3 Correct 274 ms 30968 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 1108 KB Output is correct
2 Correct 7 ms 1084 KB Output is correct
3 Correct 8 ms 1108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 3156 KB Output is correct
2 Correct 24 ms 3108 KB Output is correct
3 Correct 27 ms 3288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 9072 KB Output is correct
2 Correct 76 ms 9096 KB Output is correct
3 Correct 73 ms 9068 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 269 ms 30968 KB Output is correct
2 Correct 272 ms 30960 KB Output is correct
3 Correct 268 ms 30964 KB Output is correct