CODE FESTIVAL 2016 Final

Submission #5447414

Source codeソースコード

object Main{
	def main(args:Array[String]){
		val s = new java.util.Scanner(System.in)
		val n,m = s.nextInt
		val c = Array.fill(100001)(0)
		for(_ <- 1 to n)
			c(s.nextInt) += 1
		val a,b = Array.fill(m)(0)
		for(i <- 1 to 100000) {
			a(i % m) += c(i) % 2
			b(i % m) += c(i) / 2
		}
		println(a.mkString(" "))
		println(b.mkString(" "))
		var r = 0
		for(i <- 0 until m) {
			if(i * 2 % m == 0) {
				r += a(i) / 2
				a(i) %= 2
			} else {
				{
					val t = math.min(a(i),a(m - i))
					r += t
					a(i) -= t
					a(m - i) -= t
				}
				{
					val t = math.min(a(i) / 2,b(m - i))
					r += t * 2
					a(i) -= t * 2
					b(m - i) -= t
				}
			}
		}
		for(i <- 0 until m) {
			r += b(i)
			b(i) = 0
		}
		//println(a.mkString(" "))
		//println(b.mkString(" "))
		println(r)
	}
}

Submission

Task問題 D - Pair Cards
User nameユーザ名 ふぁる
Created time投稿日時
Language言語 Scala (2.11.7)
Status状態 WA
Score得点 0
Source lengthソースコード長 786 Byte
File nameファイル名
Exec time実行時間 ms
Memory usageメモリ使用量 -

Test case

Set

Set name Score得点 / Max score Cases
sample - sample-01.txt,sample-02.txt
all 0 / 700 sample-01.txt,sample-02.txt,01-01.txt,01-02.txt,01-03.txt,01-04.txt,01-05.txt,01-06.txt,01-07.txt,01-08.txt,01-09.txt,01-10.txt,01-11.txt,01-12.txt,01-13.txt,01-14.txt,01-15.txt,01-16.txt,01-17.txt,01-18.txt,01-19.txt,01-20.txt,01-21.txt,01-22.txt,01-23.txt,01-24.txt,01-25.txt,01-26.txt,01-27.txt,01-28.txt,01-29.txt,01-30.txt,sample-01.txt,sample-02.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
01-01.txt WA
01-02.txt WA
01-03.txt WA
01-04.txt WA
01-05.txt WA
01-06.txt WA
01-07.txt WA
01-08.txt WA
01-09.txt WA
01-10.txt WA
01-11.txt WA
01-12.txt WA
01-13.txt WA
01-14.txt WA
01-15.txt WA
01-16.txt WA
01-17.txt WA
01-18.txt WA
01-19.txt WA
01-20.txt WA
01-21.txt WA
01-22.txt WA
01-23.txt WA
01-24.txt WA
01-25.txt WA
01-26.txt WA
01-27.txt WA
01-28.txt WA
01-29.txt WA
01-30.txt WA
sample-01.txt WA
sample-02.txt WA