Created
June 12, 2018 17:22
-
-
Save sunghun7511/033cfc125332bf3d04435b7827e540ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
) | |
func up(a int) int { | |
if a >= 10 { | |
return a / 10 | |
} else { | |
return a | |
} | |
} | |
func main(){ | |
var y int | |
var n, n2, n3 [10]int | |
var out, out2 int64 | |
fmt.Scan(&y) | |
for i := 0; i < y ; i ++ { | |
fmt.Scan(&n[i]) | |
if n[i] >= 10 { | |
n2[i] = n[i] / 10 | |
} else { | |
n2[i] = n[i] | |
} | |
n3[i] = n[i] % 10 | |
} | |
for i := 0; i < y - 1; i++ { | |
for j := i+1; j < y; j++ { | |
if n2[i] > n2[j] || (n2[i] == n2[j] && n3[i] > n3[j]){ | |
n[i], n[j] = n[j], n[i] | |
n2[i], n2[j] = n2[j], n2[i] | |
n3[i], n3[j] = n3[j], n3[i] | |
} | |
} | |
} | |
out = 0 | |
for i := 0 ; i < y ; i ++ { | |
if n[i] >= 10 { | |
out *= 10 | |
} | |
out *= 10 | |
out += int64(n[i]) | |
} | |
out2 = 0 | |
for i := y - 1 ; i >= 0 ; i -- { | |
if n[i] >= 10 { | |
out2 *= 10 | |
} | |
out2 *= 10 | |
out2 += int64(n[i]) | |
} | |
fmt.Printf("%d", out + out2) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment