Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

gattaca

  • Loading branch information...
commit d733a5e6655979e0c7d70c8fe66f9c737ef53ece 1 parent 65171fd
Tianyi Cui authored

Showing 2 changed files with 47 additions and 0 deletions. Show diff stats Hide diff stats

  1. +35 0 gattaca/gattaca
  2. +12 0 gattaca/gattaca.in
35 gattaca/gattaca
... ... @@ -0,0 +1,35 @@
  1 +#!/usr/bin/env ruby
  2 +
  3 +f = open(ARGV[0])
  4 +n = f.readline.to_i
  5 +((n+79)/80).times do
  6 + f.readline
  7 +end
  8 +
  9 +m = f.readline.to_i
  10 +seq = []
  11 +m.times do
  12 + s = f.readline.split.map{|o| o.to_i}
  13 + s[0] += 1
  14 + s[1] += 1
  15 + seq << s
  16 +end
  17 +seq = seq.sort_by {|o| o[1]}
  18 +seq << [n + 1, n + 1, 0]
  19 +
  20 +S = [0] * (n + 2)
  21 +
  22 +solved = 0
  23 +
  24 +seq.each do |s|
  25 + start = s[0]
  26 + stop = s[1]
  27 + score = s[2]
  28 + (solved...stop).each do |i|
  29 + S[i+1] = [S[i+1], S[i]].max
  30 + end
  31 + S[stop] = [S[stop], S[start-1] + score].max
  32 + solved = stop
  33 +end
  34 +
  35 +puts S[n+1]
12 gattaca/gattaca.in
... ... @@ -0,0 +1,12 @@
  1 +100
  2 +GAACTATCGCCCGTGCGCATCGCCCGTCCGACCGGCCGTAAGTCTATCTCCCGAGCGGGCGCCCGATCTCAAGTGCACCT
  3 +CACGGCCTCACGACCGTGAG
  4 +8
  5 +43 70 27
  6 +3 18 24
  7 +65 99 45
  8 +20 39 26
  9 +45 74 26
  10 +10 28 20
  11 +78 97 23
  12 +0 9 22

0 comments on commit d733a5e

Please sign in to comment.
Something went wrong with that request. Please try again.