# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
124383 | 2019-07-03T09:01:48 Z | AyaBenSaad | Strange Device (APIO19_strange_device) | C++14 | 493 ms | 32396 KB |
#include <bits/stdc++.h> #define ll long long using namespace std; const int M = 1e6 + 6; int n; ll a, b; stack <pair <ll, ll> > s; pair <ll, ll> t[M]; bool inter (ll a, ll b) { ll x = s.top().first; ll y = s.top().second; return ((a <= y && a >= x) || (b <= y && b >= x)); } int main () { scanf ("%d %lld %lld", &n, &a, &b); for (int i = 0; i < n; i++) { scanf ("%lld %lld", &t[i].first, &t[i].second); } sort (t, t+n); for (int i = 0; i < n; i++) { if (s.empty() || !inter(t[i].first, t[i].second)) { s.push ({t[i].first, t[i].second}); } else { long long x = min (t[i].first, s.top().first); long long y = max (t[i].second, s.top().second); s.pop(); s.push({x, y}); } } long long ans = 0; while (s.size()) { ans += s.top().second - s.top().first + 1; s.pop(); } printf ("%lld\n", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 6 ms | 632 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 2 ms | 256 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 3 ms | 376 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 493 ms | 32396 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 493 ms | 32396 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Incorrect | 493 ms | 32396 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 49 ms | 3532 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Incorrect | 6 ms | 632 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |