Submission #54353

# Submission time Handle Problem Language Result Execution time Memory
54353 2018-07-03T08:06:11 Z 강태규(#1471) Sails (IOI07_sails) C++11
10 / 100
68 ms 11844 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int n;
pii hk[100000];
int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        int h, k;
        scanf("%d%d", &h, &k);
        hk[i] = pii(h, k);
    }
    sort(hk, hk + n);
    int mh = hk[n - 1].first;
    
    multiset<int> mp;
    multiset<int>::iterator it, it2;
    for (int i = 0; i < n; ++i) mp.insert(mh + 1);
    for (int i = 0; i < n; ++i) {
        int h = mh - hk[i].first + 1;
        int x = h + hk[i].second;
        mp.insert(h);
        it = mp.upper_bound(x);
        it2 = it--;
        int a = *it;
        int b = *it2;
        mp.erase(it);
        mp.erase(it2);
        mp.insert(b - (x - a));
    }
    llong ans = 0;
    it = mp.begin();
    for (int i = 0, pr = 0; it != mp.end(); ++i, pr = *it, ++it) {
        ans += (llong)i * (i - 1) * (*it - pr);
    }
    printf("%lld\n", ans / 2);
    
	return 0;
}

Compilation message

sails.cpp: In function 'int main()':
sails.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
sails.cpp:27:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &h, &k);
         ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 376 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 608 KB Output is correct
2 Correct 2 ms 640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 712 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 744 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 856 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1276 KB Output is correct
2 Runtime error 21 ms 4192 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 19 ms 4192 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 35 ms 6400 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Runtime error 53 ms 9184 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 61 ms 10896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 68 ms 11844 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -