# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
660561 | 2022-11-22T09:45:07 Z | 600Mihnea | 사다리꼴 (balkan11_trapezoid) | C++17 | 500 ms | 5320 KB |
bool home = 0; #include <bits/stdc++.h> using namespace std; const int MODULO = 30013; struct T { int a; int b; int c; int d; }; bool operator < (T first, T second) { return first.b < second.b; } int main() { if (home == 0) { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); } else { freopen ("input.txt", "r", stdin); } int n; cin >> n; vector<T> v(n); for (auto &it : v) { cin >> it.a >> it.b >> it.c >> it.d; } sort(v.begin(), v.end()); vector<int> dp(n, 0), ways(n, 0); for (int i = 0; i < n; i++) { dp[i] = 1; ways[i] = 1; for (int j = 0; j < i; j++) { if (v[j].b < v[i].a && v[j].d < v[i].c) { if (dp[j] + 1 > dp[i]) { dp[i] = dp[j] + 1; ways[i] = ways[j]; } else { if (dp[j] + 1 == dp[i]) { ways[i] = (ways[i] + ways[j]) % MODULO; } } } } } int mx = *max_element(dp.begin(), dp.end()), cnt = 0; for (int i = 0; i < n; i++) { if (dp[i] == mx) { cnt = (cnt + ways[i]) % MODULO; } } cout << mx << " " << cnt << "\n"; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 320 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 3 ms | 368 KB | Output is correct |
5 | Correct | 7 ms | 340 KB | Output is correct |
6 | Correct | 15 ms | 468 KB | Output is correct |
7 | Correct | 17 ms | 508 KB | Output is correct |
8 | Correct | 14 ms | 468 KB | Output is correct |
9 | Correct | 109 ms | 724 KB | Output is correct |
10 | Correct | 422 ms | 1316 KB | Output is correct |
11 | Execution timed out | 937 ms | 1576 KB | Time limit exceeded |
12 | Execution timed out | 1045 ms | 2752 KB | Time limit exceeded |
13 | Execution timed out | 1057 ms | 3404 KB | Time limit exceeded |
14 | Execution timed out | 1053 ms | 3896 KB | Time limit exceeded |
15 | Execution timed out | 1076 ms | 4036 KB | Time limit exceeded |
16 | Execution timed out | 1051 ms | 4248 KB | Time limit exceeded |
17 | Execution timed out | 1074 ms | 4592 KB | Time limit exceeded |
18 | Execution timed out | 1073 ms | 4812 KB | Time limit exceeded |
19 | Execution timed out | 1067 ms | 4996 KB | Time limit exceeded |
20 | Execution timed out | 1076 ms | 5320 KB | Time limit exceeded |