Submission #851814

# Submission time Handle Problem Language Result Execution time Memory
851814 2023-09-20T16:20:05 Z AliMark71 Unija (COCI17_unija) C++17
80 / 100
1000 ms 50912 KB
//
//  main.cpp
//  GeneralCompetitiveProgramming
//
//  Created by Ali AlSalman on 12/07/2023.
//

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <numeric>
#include <cmath>
#include <climits>

#define endl '\n'

using namespace std;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    
    int n;
    cin>>n;
    
    map<int, int> mp;
    while (n--) {
        int x, y;
        cin>>x>>y;
        x /= 2; y /= 2;
        mp[x] = max(mp[x], y);
    }
    
    long long size = 0;
    for (auto i = mp.rbegin(); i != mp.rend(); i++) {
        if (next(i) == mp.rend()) {
            size += (long long) i->first * i->second;
            break;
        }
        
        size += (long long) (i->first - next(i)->first) * (i->second);
        next(i)->second = max(next(i)->second, i->second);
    }
    
    cout<<4 * size<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 2 ms 600 KB Output is correct
3 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1022 ms 35756 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 1340 KB Output is correct
2 Correct 12 ms 1368 KB Output is correct
3 Correct 12 ms 1372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 3924 KB Output is correct
2 Correct 45 ms 3920 KB Output is correct
3 Correct 45 ms 3920 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 155 ms 11152 KB Output is correct
2 Correct 171 ms 10980 KB Output is correct
3 Correct 149 ms 11012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 951 ms 35516 KB Output is correct
2 Correct 935 ms 50632 KB Output is correct
3 Execution timed out 1027 ms 50912 KB Time limit exceeded
4 Halted 0 ms 0 KB -