{"id":5620,"date":"2022-10-03T01:40:39","date_gmt":"2022-10-02T16:40:39","guid":{"rendered":"https:\/\/suzutukiblog.com\/?p=5620"},"modified":"2022-10-17T10:02:21","modified_gmt":"2022-10-17T01:02:21","slug":"tips-5","status":"publish","type":"post","link":"https:\/\/suzutukiblog.com\/index.php\/2022\/10\/03\/tips-5\/","title":{"rendered":"TIPS(Ruby:\u57fa\u672c\u7684\u306a\u30dd\u30a4\u30f3\u30c8\u30ab\u30fc\u30c9\u6a5f\u80fd\u306e\u4f5c\u308a\u65b9)"},"content":{"rendered":"<h3>\u76ee\u6a19<\/h3>\n<p>\u30dd\u30a4\u30f3\u30c8\u30ab\u30fc\u30c9\u306e\u57fa\u672c\u7684\u306a\u90e8\u5206\u3092\u4f5c\u6210\u3059\u308b\u3002<br \/>\n\u30dd\u30a4\u30f3\u30c8\u306e\u7372\u5f97\u6a5f\u80fd<br \/>\n\u6761\u4ef6\u3092\u6e80\u305f\u3057\u305f\u3068\u304d\u306b\u30dd\u30a4\u30f3\u30c8\u6d88\u8cbb\u3059\u308b\u6a5f\u80fd<\/p>\n<h3>\u554f\u984c<\/h3>\n<p>\u8cb7\u3044\u7269\u306e\u652f\u6255\u3044\u306b\u73fe\u91d1\u3067\u306f\u306a\u304fsuzuca\u306b\u30c1\u30e3\u30fc\u30b8\u3057\u3066\u5229\u7528\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u8cb7\u3044\u7269\u306e\u652f\u6255\u3044\u306bsuzuca\u306e\u30ab\u30fc\u30c9\u6b8b\u984d\u3092\u4f7f\u3046\u3068\u3001<br \/>\n\u8cb7\u7269\u91d1\u984d\u306e 10 % \u304c suzuca\u30dd\u30a4\u30f3\u30c8\u3068\u3057\u3066\u305f\u307e\u308a\u307e\u3059\u3002<br \/>\n\u8cb7\u3044\u7269\u3092\u3059\u308b\u6642\u306b\u3001\u652f\u6255\u3046\u904b\u8cc3\u4ee5\u4e0a\u306esuzuca \u30dd\u30a4\u30f3\u30c8\u304c\u3042\u308b\u5834\u5408\u306f\u3001<br \/>\nsuzuca\u30dd\u30a4\u30f3\u30c8\u304c\u512a\u5148\u7684\u306b\u8cb7\u3044\u7269\u306e\u652f\u6255\u3044\u306b\u4f7f\u308f\u308c\u307e\u3059\u3002<br \/>\n\u305f\u3060\u3057\u30011 \u30dd\u30a4\u30f3\u30c8\u306f 1 \u5186\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u30dd\u30a4\u30f3\u30c8\u3067\u8cb7\u3044\u7269\u3092\u652f\u6255\u3063\u305f\u5834\u5408\u3001\u65b0\u305f\u306a\u30dd\u30a4\u30f3\u30c8\u306f\u767a\u751f\u3057\u307e\u305b\u3093\u3002<\/p>\n<p>\u6700\u521d\u306b\u30c1\u30e3\u30fc\u30b8\u3059\u308b\u73fe\u91d1\u3068\u3001\u8cb7\u3044\u7269\u6642\u306b\u304b\u304b\u3063\u305f\u6599\u91d1\u306e\u30ea\u30b9\u30c8\u304c\u4e0e\u3048\u3089\u308c\u308b\u306e\u3067\u3001<br \/>\n\u6bce\u56de\u306e\u8cb7\u3044\u7269\u6642\u306b\u6b8b\u3063\u3066\u3044\u308b\u304a\u91d1\u3068\u30dd\u30a4\u30f3\u30c8\u3092\u51fa\u529b\u3057\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<p>\u305f\u3060\u3057\u3001\u9014\u4e2d\u3067\u30ab\u30fc\u30c9\u6b8b\u9ad8\u3068\u30dd\u30a4\u30f3\u30c8\u306e\u4e21\u65b9\u304c\u8cb7\u3044\u7269\u306e\u91d1\u984d\u3092\u4e0b\u56de\u308b\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n<h3>\u4e0e\u3048\u3089\u308c\u308b\u5165\u529b\u5024<\/h3>\n<pre class=\"sample-content__input\"><code>5000 5\r\n200\r\n300\r\n500\r\n100\r\n100<\/code><\/pre>\n<h3>\u671f\u5f85\u3059\u308b\u51fa\u529b<\/h3>\n<pre><code class=\"stdout ng-binding\">4800 20\r\n4500 50\r\n4000 100\r\n4000 0\r\n3900 10<\/code><\/pre>\n<h3>\u30b3\u30fc\u30c9\u3068\u89e3\u8aac<\/h3>\n<pre>#1\u884c\u76ee\u306e\u5165\u529b\u5024\u3092\u53d7\u3051\u53d6\u308b\r\nn,m = gets.split.map(&amp;:to_i)\r\n\r\n#\u30dd\u30a4\u30f3\u30c8\u306f\u6700\u521d\u306f0\u306a\u306e\u30670\r\npoint = 0\r\n\r\n#2\u884c\u76ee\u304b\u30896\u884c\u76ee\u307e\u3067\u3092\u5148\u306b\u914d\u5217\u3068\u3057\u3066\u53d7\u3051\u53d6\u308b\r\nplice = readlines.map(&amp;:to_i)\r\n\r\nplice.each do |i|\r\n#\u6301\u3063\u3066\u3044\u308b\u30dd\u30a4\u30f3\u30c8\u3088\u308a\u5024\u6bb5\u304c\u4f4e\u3044\u3068\u304d\u306b\u30dd\u30a4\u30f3\u30c8\u3092\u6d88\u8cbb\u3059\u308b\r\n  if i &lt;= point\r\n     point = point - i\r\n#\u30c1\u30e3\u30fc\u30b8\u91d1\u984d\u304b\u3089\u5024\u6bb5\u3092\u5dee\u3057\u5f15\u304d\u3059\u308b\r\n  else n = n - i\r\n#\u5024\u6bb5\u306e\u91d1\u984d\u306e10\u5206\u306e1\u306e\u30dd\u30a4\u30f3\u30c8\u3092\u5f97\u308b\r\n     point += i \/ 10\r\n  end\r\n\u8cb7\u3044\u7269\u3054\u3068\u306esuzuca\u306e\u30c1\u30e3\u30fc\u30b8\u91d1\u984d\u3068\u30dd\u30a4\u30f3\u30c8\u6570\u3092\u51fa\u529b\u3059\u308b\r\n  puts n.to_s + \" \" + point.to_s\r\nend<\/pre>\n<p><a href=\"https:\/\/paiza.io\/ja\/projects\/new\">https:\/\/paiza.io\/ja\/projects\/new<\/a><\/p>\n<p>\u2191\u3053\u3061\u3089\u306b\u30b3\u30d4\u30da\u3057\u3066\u300c\u5b9f\u884c\u300d\u3067\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u2193\u3053\u306e\u3088\u3046\u306a\u51fa\u529b\u7d50\u679c\u306b\u306a\u3063\u3066\u3044\u3066\u3044\u308c\u3070OK\u3067\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-5617\" src=\"https:\/\/suzutukiblog.com\/wp-content\/uploads\/2022\/09\/72e895510fda97bf8e10c2b5ba710e5d.png\" alt=\"\" width=\"190\" height=\"236\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u6a19 \u30dd\u30a4\u30f3\u30c8\u30ab\u30fc\u30c9\u306e\u57fa\u672c\u7684\u306a\u90e8\u5206\u3092\u4f5c\u6210\u3059\u308b\u3002 \u30dd\u30a4\u30f3\u30c8\u306e\u7372\u5f97\u6a5f\u80fd \u6761\u4ef6\u3092\u6e80\u305f\u3057\u305f\u3068\u304d\u306b\u30dd\u30a4\u30f3\u30c8\u6d88\u8cbb\u3059\u308b\u6a5f\u80fd \u554f\u984c \u8cb7\u3044\u7269\u306e\u652f\u6255\u3044\u306b\u73fe\u91d1\u3067\u306f\u306a\u304fsuzuca\u306b\u30c1\u30e3\u30fc\u30b8\u3057\u3066\u5229\u7528\u3057\u3066\u3044\u307e\u3059\u3002 \u8cb7\u3044\u7269\u306e\u652f\u6255\u3044\u306bsuzuca\u306e\u30ab [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2684,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[27],"tags":[],"class_list":["post-5620","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming-note"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/posts\/5620","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/comments?post=5620"}],"version-history":[{"count":3,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/posts\/5620\/revisions"}],"predecessor-version":[{"id":5623,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/posts\/5620\/revisions\/5623"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/media\/2684"}],"wp:attachment":[{"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/media?parent=5620"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/categories?post=5620"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/suzutukiblog.com\/index.php\/wp-json\/wp\/v2\/tags?post=5620"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}