CODE FESTIVAL 2016 Final

Submission #5447419

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状態 AC
Score得点 700
Source lengthソースコード長 789 Byte
File nameファイル名
Exec time実行時間 739 ms
Memory usageメモリ使用量 51988 KB

Test case

Set

Set name Score得点 / Max score Cases
sample - sample-01.txt,sample-02.txt
all 700 / 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 AC 378 ms 26136 KB
01-02.txt AC 678 ms 48092 KB
01-03.txt AC 683 ms 48208 KB
01-04.txt AC 677 ms 48160 KB
01-05.txt AC 674 ms 48276 KB
01-06.txt AC 681 ms 48080 KB
01-07.txt AC 670 ms 47740 KB
01-08.txt AC 677 ms 48192 KB
01-09.txt AC 685 ms 47204 KB
01-10.txt AC 700 ms 48044 KB
01-11.txt AC 710 ms 47308 KB
01-12.txt AC 678 ms 47880 KB
01-13.txt AC 688 ms 48028 KB
01-14.txt AC 695 ms 47924 KB
01-15.txt AC 671 ms 48156 KB
01-16.txt AC 689 ms 48124 KB
01-17.txt AC 687 ms 48160 KB
01-18.txt AC 700 ms 48376 KB
01-19.txt AC 689 ms 48220 KB
01-20.txt AC 739 ms 51988 KB
01-21.txt AC 690 ms 51784 KB
01-22.txt AC 681 ms 48364 KB
01-23.txt AC 677 ms 48160 KB
01-24.txt AC 689 ms 48332 KB
01-25.txt AC 703 ms 48152 KB
01-26.txt AC 726 ms 49312 KB
01-27.txt AC 697 ms 42400 KB
01-28.txt AC 534 ms 33860 KB
01-29.txt AC 438 ms 28444 KB
01-30.txt AC 411 ms 28096 KB
sample-01.txt AC 374 ms 25880 KB
sample-02.txt AC 373 ms 25544 KB