# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
889560 | 2023-12-20T02:29:08 Z | rukashii | 이상한 기계 (APIO19_strange_device) | C++17 | 228 ms | 34268 KB |
#include <bits/stdc++.h> using namespace std; #define file if (fopen("input.txt", "r")) { freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); } #define int long long void setIn(string s) { freopen(s.c_str(), "r", stdin); } void setOut(string s) { freopen(s.c_str(), "w", stdout); } void setIO(string s = "") { if (s.size()) setIn(s+".inp"), setOut(s+".out"); } const int allmaxn = 1e6 + 2; int n, A, B, l[allmaxn], r[allmaxn]; namespace Sub1 { bool Check() { int S = 0; for (int i = 1; i <= n; i++) S += (r[i] - l[i] + 1); return (S <= 1e6); } void solve() { set <pair <int, int>> s; for (int i = 1; i <= n; i++) { for (int j = l[i]; j <= r[i]; j++) { s.insert({(j + j / B) % A, j % B}); } } cout << s.size(); } } // namespace Sub1 namespace Sub2 { bool Check() { return (n == 1); } void solve() { int len = r[1] - l[1] + 1; int ans = max(len % B, (len / B) % A); cout << ans << '\n'; } } // namespace Sub2 signed main() { // setIO(); file; ios::sync_with_stdio(0); cin.tie(0); cin >> n >> A >> B; for (int i = 1; i <= n; i++) cin >> l[i] >> r[i]; if (Sub1::Check()) return Sub1::solve(), 0; if (Sub2::Check()) return Sub2::solve(), 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2392 KB | Output is correct |
2 | Correct | 32 ms | 14428 KB | Output is correct |
3 | Correct | 54 ms | 20132 KB | Output is correct |
4 | Correct | 2 ms | 2908 KB | Output is correct |
5 | Correct | 1 ms | 2396 KB | Output is correct |
6 | Correct | 1 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 2652 KB | Output is correct |
8 | Correct | 1 ms | 2396 KB | Output is correct |
9 | Correct | 6 ms | 3164 KB | Output is correct |
10 | Correct | 0 ms | 2396 KB | Output is correct |
11 | Correct | 1 ms | 2396 KB | Output is correct |
12 | Correct | 1 ms | 2396 KB | Output is correct |
13 | Correct | 0 ms | 2396 KB | Output is correct |
14 | Correct | 1 ms | 2648 KB | Output is correct |
15 | Correct | 31 ms | 9048 KB | Output is correct |
16 | Correct | 20 ms | 9036 KB | Output is correct |
17 | Correct | 40 ms | 12880 KB | Output is correct |
18 | Correct | 1 ms | 2396 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Incorrect | 0 ms | 2396 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2396 KB | Output is correct |
2 | Correct | 100 ms | 34268 KB | Output is correct |
3 | Correct | 125 ms | 34132 KB | Output is correct |
4 | Correct | 102 ms | 32704 KB | Output is correct |
5 | Incorrect | 171 ms | 15996 KB | Output isn't correct |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2392 KB | Output is correct |
2 | Incorrect | 228 ms | 15952 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2392 KB | Output is correct |
2 | Incorrect | 228 ms | 15952 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2392 KB | Output is correct |
2 | Incorrect | 228 ms | 15952 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2396 KB | Output is correct |
2 | Incorrect | 23 ms | 6744 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2392 KB | Output is correct |
2 | Correct | 32 ms | 14428 KB | Output is correct |
3 | Correct | 54 ms | 20132 KB | Output is correct |
4 | Correct | 2 ms | 2908 KB | Output is correct |
5 | Correct | 1 ms | 2396 KB | Output is correct |
6 | Correct | 1 ms | 2396 KB | Output is correct |
7 | Correct | 1 ms | 2652 KB | Output is correct |
8 | Correct | 1 ms | 2396 KB | Output is correct |
9 | Correct | 6 ms | 3164 KB | Output is correct |
10 | Correct | 0 ms | 2396 KB | Output is correct |
11 | Correct | 1 ms | 2396 KB | Output is correct |
12 | Correct | 1 ms | 2396 KB | Output is correct |
13 | Correct | 0 ms | 2396 KB | Output is correct |
14 | Correct | 1 ms | 2648 KB | Output is correct |
15 | Correct | 31 ms | 9048 KB | Output is correct |
16 | Correct | 20 ms | 9036 KB | Output is correct |
17 | Correct | 40 ms | 12880 KB | Output is correct |
18 | Correct | 1 ms | 2396 KB | Output is correct |
19 | Correct | 1 ms | 2396 KB | Output is correct |
20 | Incorrect | 0 ms | 2396 KB | Output isn't correct |
21 | Halted | 0 ms | 0 KB | - |