Submission #1229457
Source Code Expand
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n=0,d=0) Array.new(n,d)end
def na2(n=0,m=0,d=0) Array.new(n){Array.new(m,d)}end
def na3(n=0,m=0,l=0,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
def rekkyo(a,b,d,n)
if d == a.size
b.push(n)
return
end
rekkyo(a,b,d+1,n)
rekkyo(a,b,d+1,n+a[d])
end
n,x = inp
d1 = []
m = n/2
m.times{d1.push(inp[0])}
d2 = []
(n-m).times{d2.push(inp[0])}
a1 = []
a2 = []
rekkyo(d1,a1,0,0)
rekkyo(d2,a2,0,0)
a1.sort!()
a2.sort!{|b,a| a<=>b}
h1={}
h2={}
a1.each do |d|
h1[d] = 0 if(h1[d] == nil)
h1[d] += 1
end
a2.each do |d|
h2[d] = 0 if(h2[d] == nil)
h2[d] += 1
end
ind1 = 0
ind2 = 0
ans = 0
used = {}
while(true)
break if(ind1 >= a1.size)
break if(ind2 >= a2.size)
drf = a1[ind1]+a2[ind2]
if(h1[a1[ind1]] == false)
ind1+=1
next
elsif(h2[a2[ind2]] == false)
ind2+=1
next
end
if(drf < x)
ind1+=1
elsif(drf > x)
ind2+=1
else
ans+=h1[a1[ind1]] * h2[a2[ind2]]
h1[a1[ind1]] = false
h2[a2[ind2]] = false
ind1+=1
end
end
p ans
Submission Info
Submission Time
2017-04-19 21:43:44+0900
Task
C - 無駄なものが嫌いな人
User
zazaboon
Language
Ruby (2.3.3)
Score
100
Code Size
1469 Byte
Status
AC
Exec Time
219 ms
Memory
11572 KB
Compile Error
./Main.rb:2: warning: assigned but unused variable - a
./Main.rb:3: warning: assigned but unused variable - a
./Main.rb:11: warning: assigned but unused variable - a
./Main.rb:45: warning: assigned but unused variable - used
Judge Result
Set Name
All
Score / Max Score
100 / 100
Status
Set Name
Test Cases
All
max_1.txt, max_2.txt, max_3.txt, max_4.txt, pair_1.txt, pair_2.txt, power2_1.txt, power2_2.txt, power2_3.txt, power2_4.txt, power2_5.txt, random_1.txt, random_2.txt, random_3.txt, random_4.txt, random_5.txt, random_6.txt, random_7.txt, random_8.txt, random_9.txt, sample_1.txt, sample_2.txt, sample_3.txt, sample_4.txt, small_1.txt, small_2.txt, small_3.txt, small_4.txt
Case Name
Status
Exec Time
Memory
max_1.txt
AC
169 ms
3636 KB
max_2.txt
AC
177 ms
3636 KB
max_3.txt
AC
168 ms
3636 KB
max_4.txt
AC
169 ms
3636 KB
pair_1.txt
AC
201 ms
6324 KB
pair_2.txt
AC
172 ms
3636 KB
power2_1.txt
AC
175 ms
5328 KB
power2_2.txt
AC
177 ms
3636 KB
power2_3.txt
AC
194 ms
3636 KB
power2_4.txt
AC
165 ms
3636 KB
power2_5.txt
AC
23 ms
2680 KB
random_1.txt
AC
180 ms
9136 KB
random_2.txt
AC
181 ms
9136 KB
random_3.txt
AC
192 ms
11572 KB
random_4.txt
AC
219 ms
11316 KB
random_5.txt
AC
173 ms
3636 KB
random_6.txt
AC
145 ms
3508 KB
random_7.txt
AC
176 ms
3636 KB
random_8.txt
AC
196 ms
5684 KB
random_9.txt
AC
179 ms
9136 KB
sample_1.txt
AC
7 ms
1788 KB
sample_2.txt
AC
7 ms
1788 KB
sample_3.txt
AC
10 ms
1912 KB
sample_4.txt
AC
8 ms
1788 KB
small_1.txt
AC
7 ms
1788 KB
small_2.txt
AC
7 ms
1788 KB
small_3.txt
AC
7 ms
1788 KB
small_4.txt
AC
7 ms
1788 KB