# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
555384 | 2022-04-30T19:15:53 Z | LucaDantas | Group Photo (JOI21_ho_t3) | C++17 | 3 ms | 340 KB |
#include <bits/stdc++.h> using namespace std; constexpr int maxn = 11; int a[maxn], b[maxn]; bool mark[maxn]; bool valid(int n) { for(int i = 1; i < n; i++) if(b[i] + 2 <= b[i-1]) return 0; return 1; } int get(int n) { memset(mark, 1, sizeof mark); int ans = 0; for(int i = 0; i < n; i++) { for(int j = 0; a[j] != b[i]; j++) ans += mark[a[j]]; mark[b[i]] = 0; } return ans; } int main() { int n; scanf("%d", &n); for(int i = 0; i < n; i++) scanf("%d", &a[i]); iota(b, b+n, 1); int ans = 0x3f3f3f3f; do { if(valid(n)) ans = min(ans, get(n)); } while(next_permutation(b, b+n)); printf("%d\n", ans); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 296 KB | Output is correct |
7 | Correct | 3 ms | 300 KB | Output is correct |
8 | Correct | 2 ms | 212 KB | Output is correct |
9 | Correct | 3 ms | 300 KB | Output is correct |
10 | Correct | 3 ms | 212 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 296 KB | Output is correct |
7 | Correct | 3 ms | 300 KB | Output is correct |
8 | Correct | 2 ms | 212 KB | Output is correct |
9 | Correct | 3 ms | 300 KB | Output is correct |
10 | Correct | 3 ms | 212 KB | Output is correct |
11 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 296 KB | Output is correct |
7 | Correct | 3 ms | 300 KB | Output is correct |
8 | Correct | 2 ms | 212 KB | Output is correct |
9 | Correct | 3 ms | 300 KB | Output is correct |
10 | Correct | 3 ms | 212 KB | Output is correct |
11 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 296 KB | Output is correct |
7 | Correct | 3 ms | 300 KB | Output is correct |
8 | Correct | 2 ms | 212 KB | Output is correct |
9 | Correct | 3 ms | 300 KB | Output is correct |
10 | Correct | 3 ms | 212 KB | Output is correct |
11 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
12 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 296 KB | Output is correct |
7 | Correct | 3 ms | 300 KB | Output is correct |
8 | Correct | 2 ms | 212 KB | Output is correct |
9 | Correct | 3 ms | 300 KB | Output is correct |
10 | Correct | 3 ms | 212 KB | Output is correct |
11 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
12 | Halted | 0 ms | 0 KB | - |