# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
378173 | 2021-03-16T06:15:55 Z | JerryLiu06 | 이상한 기계 (APIO19_strange_device) | C++11 | 750 ms | 33552 KB |
#include <bits/stdc++.h> #include <iostream> using namespace std; typedef long long ll; typedef pair<ll, int> pli; #define f first #define s second int N; ll A, B, ans = 0; vector<pli> E; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cin >> N >> A >> B; ll MOD = A * B; if (MOD <= 0 || MOD > 1000000000000000000L) MOD = 1000000000000000010L; for (int i = 0; i < N; i++) { ll X, Y; cin >> X >> Y; X %= MOD; Y %= MOD; if (X <= Y) { E.push_back({X, 1}); E.push_back({Y, -1}); } else { E.push_back({0, 1}); E.push_back({Y, -1}); E.push_back({X, 1}); E.push_back({MOD - 1, -1}); } } sort(begin(E), end(E)); int prev = 0; int cur = 0; ll PREV = 0; ll NOW = 0; for (int i = 0; i < E.size(); ) { NOW = E[i].f; while (i < E.size() && E[i].f == NOW) cur += E[i++].s; ans++; if (prev > 0) ans += NOW - PREV - 1; prev = cur; PREV = NOW; } cout << ans << endl; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 6 ms | 1008 KB | Output is correct |
3 | Correct | 6 ms | 1008 KB | Output is correct |
4 | Incorrect | 1 ms | 364 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Incorrect | 1 ms | 364 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 1 ms | 364 KB | Output is correct |
3 | Correct | 1 ms | 364 KB | Output is correct |
4 | Correct | 1 ms | 364 KB | Output is correct |
5 | Correct | 434 ms | 33476 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 573 ms | 33552 KB | Output is correct |
3 | Incorrect | 546 ms | 33456 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 573 ms | 33552 KB | Output is correct |
3 | Incorrect | 546 ms | 33456 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 573 ms | 33552 KB | Output is correct |
3 | Incorrect | 546 ms | 33456 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 61 ms | 4580 KB | Output is correct |
3 | Correct | 61 ms | 4580 KB | Output is correct |
4 | Correct | 750 ms | 33340 KB | Output is correct |
5 | Correct | 63 ms | 4580 KB | Output is correct |
6 | Correct | 61 ms | 4580 KB | Output is correct |
7 | Correct | 61 ms | 4580 KB | Output is correct |
8 | Correct | 78 ms | 4544 KB | Output is correct |
9 | Correct | 60 ms | 4740 KB | Output is correct |
10 | Correct | 73 ms | 4580 KB | Output is correct |
11 | Correct | 66 ms | 4580 KB | Output is correct |
12 | Correct | 56 ms | 4580 KB | Output is correct |
13 | Correct | 68 ms | 4580 KB | Output is correct |
14 | Correct | 730 ms | 33340 KB | Output is correct |
15 | Incorrect | 63 ms | 4580 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 6 ms | 1008 KB | Output is correct |
3 | Correct | 6 ms | 1008 KB | Output is correct |
4 | Incorrect | 1 ms | 364 KB | Output isn't correct |
5 | Halted | 0 ms | 0 KB | - |