Skip to content

Instantly share code, notes, and snippets.

@sasamijp
Last active August 29, 2015 14:00
Show Gist options
  • Save sasamijp/a2a19fa0c9abd0d736f7 to your computer and use it in GitHub Desktop.
Save sasamijp/a2a19fa0c9abd0d736f7 to your computer and use it in GitHub Desktop.
死ね
gets
member = {
'J' => 1,
'O' => 2,
'I' => 4
}
def dumpArray(array)
array.each do |value|
puts ((" "*value)+value.to_s)
end
end
def arrayTree(array)
narray = []
point = [0]
array.each_with_index do |value, l|
if value < array[l-1] and l != 0
nnarray = []
i = 1
point.push l
loop do
nnarray.push array[l-i]
#p point[-1]
#p l-i+1
break if l-i+1 == point[-1]
i += 1
#p "a"
end
narray.push nnarray
end
end
return narray
end
keymans = [member['J']]
attends = 0
gets.chomp.split("").each do |owner|
attend = []
attendc = 0
keymans.each do |keyman|
for num in 0..7 do
if keyman & num != 0 and member[owner] & num != 0
attend[attendc] = num
attendc += 1
end
end
end
p arrayTree attend
p attend.length
keymans = attend
attends = attendc
end
puts attends
#include <stdio.h>
int main(){
int countItem, n, m, l, i;
scanf("%d %d", &n, &m);
countItem = n + m;
int competiton[n], standars[m];
int competitoncounter=0,standarscounter=0;
int mostpopularCompetitions[m], mostpopularCompetitionsCounter=0;
int numberofOccurrence, maxnumberofOccurrence=0;
int numberofOccurrences[m];
int resultsMode;
int result=0;
for(l = 0; l<countItem; l++){
if(l != 0){
if(l <= n){
scanf("%d", &competiton[competitoncounter]);
competitoncounter++;
}else{
scanf("%d", &standars[standarscounter]);
standarscounter++;
}
}
}
for(l=0; l<m; l++){
//standars[l]
for(i=0; i<competitoncounter; i++){
if(competiton[i] > standars[l]){
mostpopularCompetitions[mostpopularCompetitionsCounter] = competiton[i];
mostpopularCompetitionsCounter++;
break;
}
}
}
for(l=0; l<mostpopularCompetitionsCounter; l++){
//mostpopularCompetitions[l]
numberofOccurrence = 0;
for(i=0; i<mostpopularCompetitionsCounter; i++){
if(mostpopularCompetitions[l] == mostpopularCompetitions[i]){
numberofOccurrence++;
}
}
if(maxnumberofOccurrence< numberofOccurrence){
maxnumberofOccurrence=numberofOccurrence;
//resultsMode = mostpopularCompetitions[l];
result=l;
}
}
printf("%d\n", l);
return 0;
}
input = gets.split
n ,m = input[0].to_i, input[1].to_i
competitons = []
n.times { competitons.push(gets.to_i) }
standards = []
m.times { standards.push(gets.to_i) }
mosts = []
standards.each do |standard|
competitons.each_with_index do |competiton, l|
if standard >= competiton
mosts.push l
break
end
end
end
most = mosts.max_by{ |value| mosts.count(value) }
puts most+1
inputs = gets.split.map{ |input|input = input.to_i }
W, H, N = inputs[0], inputs[1], inputs[2]
spots = []
N.times { spots.push gets.split.map{|num| num = num.to_i } }
def distanceAB(spotA, spotB)
distance = [(spotA[0]-spotB[0]).abs, (spotA[1]-spotB[1]).abs].max
x, y = (spotA[0]-spotB[0]), (spotA[1]-spotB[1])
if( x < 0 and y > 0 ) or ( x > 0 and y < 0 )
if y.abs > x.abs
distance += x.abs
elsif y.abs < x.abs
distance += y.abs
elsif x.abs == y.abs
distance = (x.abs + y.abs)
end
end
return distance
end
roads = 0
spots.each_with_index do |spot, l|
roads += distanceAB(spots[l-1], spot) if l != 0
end
puts roads
gets
member = {
'J' => 1,
'O' => 2,
'I' => 4
}
keymans = [member['J']]
attends = []
gets.chomp.split("").each_with_index do |owner, l|
attend = []
attendc = 0
keymans.each do |keyman|
for num in 0..7 do
if keyman & num != 0 and member[owner] & num != 0
attend[attendc] = num
attendc += 1
end
end
end
keymans = attend
attends.push attendc
end
puts attends[-1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment