Skip to content

Commit b7c6988

Browse files
committed
upload ABC398
1 parent 24cdd93 commit b7c6988

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-0
lines changed

ABC398/A_0322.R

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
N <- scan("stdin", what = integer(), nmax=1, quiet = TRUE)
2+
moji <- function(){
3+
if (N %% 2 == 1){
4+
for (i in 1:N){
5+
if (i == (N+1)/2) {
6+
cat("=")
7+
} else {
8+
cat ("-")
9+
}
10+
}
11+
} else {
12+
for (i in 1:N){
13+
if (i == N/2 | i== N / 2 + 1){
14+
cat("=")
15+
} else {
16+
cat("-")
17+
}
18+
}
19+
}
20+
cat("\n")
21+
}
22+
moji()

ABC398/B_0322.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
input <- scan("stdin", what = integer(), nmax= 7, quiet = TRUE)
2+
full <- function(){
3+
freq_input <- table(input)
4+
freq <- as.numeric(freq_input)
5+
if (any(freq == 3) && any(freq == 2) |
6+
any(freq == 4) && any(freq == 2) |
7+
any(freq == 5) && any(freq == 2) |
8+
sum(freq == 3) == 2 && any(freq == 1) |
9+
any(freq == 4) && any(freq == 3)){
10+
cat("Yes\n")
11+
} else {
12+
cat("No\n")
13+
}
14+
}
15+
full()

ABC398/C_0322.R

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
input <- scan("stdin", what = integer(), quiet = TRUE)
2+
uniqueness <- function(){
3+
n <- input[1]
4+
n_list <- input[2:(n + 1)]
5+
freq_nlist <- table(n_list)
6+
freq <- as.numeric(freq_nlist)
7+
if (any(freq == 1)){
8+
unique <- as.numeric(names(freq_nlist[freq_nlist == 1]))
9+
max_unique <- max(unique)
10+
index_max <- which(n_list == max_unique)
11+
cat(index_max,"\n")
12+
} else{
13+
cat("-1\n")
14+
}
15+
}
16+
uniqueness()
17+

0 commit comments

Comments
 (0)