<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>難易度-1200 - IQパズルステップ</title>
	<atom:link href="https://chokomon.com/tag/difficulty-1200/feed/" rel="self" type="application/rss+xml" />
	<link>https://chokomon.com</link>
	<description>ちょこっと頭を良くするIQパズル問題集</description>
	<lastBuildDate>Sun, 18 Sep 2022 04:38:11 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://chokomon.com/wp-content/uploads/2022/02/cropped-icon512-32x32.png</url>
	<title>難易度-1200 - IQパズルステップ</title>
	<link>https://chokomon.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>【累積和メニュー】区間の長さ 3 (paizaランク C)-解答例-PHP編</title>
		<link>https://chokomon.com/27-prefix_sum_problems-09-03-00653/</link>
					<comments>https://chokomon.com/27-prefix_sum_problems-09-03-00653/#respond</comments>
		
		<dc:creator><![CDATA[東鳥子]]></dc:creator>
		<pubDate>Sun, 18 Sep 2022 04:38:10 +0000</pubDate>
				<category><![CDATA[paiza-問題集]]></category>
		<category><![CDATA[累積和メニュー]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ランクC]]></category>
		<category><![CDATA[難易度-1200]]></category>
		<guid isPermaLink="false">https://chokomon.com/?p=6906</guid>

					<description><![CDATA[【累積和メニュー】> 【区間の長さ】STEP: 3 区間の長さ 3 (paizaランク C 相当) [難易度: 1214 ±66] ※リンク先へ移動するためには[paiza]へのログインが必要です。 解答例]]></description>
										<content:encoded><![CDATA[
<p>【<a href="https://chokomon.com/paiza_mondai/27-prefix_sum_problems/">累積和メニュー</a>】> <a href="https://paiza.jp/works/mondai/prefix_sum_problems/prefix_sum_problems__syakutori_length_step3" target="_blank" rel="noreferrer noopener">【区間の長さ】STEP: 3 区間の長さ 3 (paizaランク C 相当)</a> [難易度: <strong>1214 ±66</strong>]



<p>※リンク先へ移動するためには[<a href="https://paiza.jp/works" target="_blank" rel="noreferrer noopener">paiza</a>]へのログインが必要です。</p>



<figure class="wp-block-image aligncenter size-full"><img fetchpriority="high" decoding="async" width="660" height="300" src="https://chokomon.com/wp-content/uploads/2022/09/27-09-03-01.png" alt="" class="wp-image-6907"/></figure>



<div class="wp-block-dvaux-frame sc_frame_wrap inline"><div class="sc_frame_title inline" style="background-color:#ccc">問題文</div><div class="sc_frame" style="background-color:#fff;border-color:#ccc">
<p>1 行目に整数 K が与えられます。</p>



<p>10 個の整数 a_1, a_2, ..., a_10 からなる数列 a が与えられます。</p>



<p>この数列において、総和が K 以下の区間のうち、最大の長さを求めてください。</p>



<p></p>



<p><strong>入力値（例）</strong><br>15<br>1 5 9 1 20 5 3 6 5 4</p>



<p><strong>出力値（例）</strong><br>3</p>
</div></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">解答例</h2>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">&lt;?php
    $k = trim(fgets(STDIN));
    $a = explode(" ", trim(fgets(STDIN)));
    
    $maxLength = 0;
    
    for ($i=0; $i&lt;count($a); $i++) {
        $r = $i+1;
        $sectionSum = 0;
        while ($r &lt; count($a)+1) {
            $sectionSum += $a[$r-1];
            if ($sectionSum &gt; $k) break;
            $r++;
        }
        $maxLength = max($maxLength, $r-$i-1);
    }
    echo $maxLength;
?&gt;</pre></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image aligncenter size-full"><img decoding="async" width="660" height="160" src="https://chokomon.com/wp-content/uploads/2022/09/27-09-03-02.png" alt="" class="wp-image-6908"/></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://chokomon.com/27-prefix_sum_problems-09-03-00653/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【累積和メニュー】1 次元上のいもす法 3 (paizaランク C)-解答例-PHP編</title>
		<link>https://chokomon.com/27-prefix_sum_problems-06-03-00639/</link>
					<comments>https://chokomon.com/27-prefix_sum_problems-06-03-00639/#respond</comments>
		
		<dc:creator><![CDATA[東鳥子]]></dc:creator>
		<pubDate>Tue, 13 Sep 2022 06:26:08 +0000</pubDate>
				<category><![CDATA[paiza-問題集]]></category>
		<category><![CDATA[累積和メニュー]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ランクC]]></category>
		<category><![CDATA[難易度-1200]]></category>
		<guid isPermaLink="false">https://chokomon.com/?p=6826</guid>

					<description><![CDATA[【累積和メニュー】> 【1 次元上のいもす法】STEP: 3 1 次元上のいもす法 3 (paizaランク C 相当) [難易度: 1232 ±52] ※リンク先へ移動するためには[paiza]へのログインが必要です。 解答例]]></description>
										<content:encoded><![CDATA[
<p>【<a href="https://chokomon.com/paiza_mondai/27-prefix_sum_problems/">累積和メニュー</a>】> <a href="https://paiza.jp/works/mondai/prefix_sum_problems/prefix_sum_problems__1d_imos_step3" target="_blank" rel="noreferrer noopener">【1 次元上のいもす法】STEP: 3 1 次元上のいもす法 3 (paizaランク C 相当)</a> [難易度: <strong>1232 ±52</strong>]



<p>※リンク先へ移動するためには[<a href="https://paiza.jp/works" target="_blank" rel="noreferrer noopener">paiza</a>]へのログインが必要です。</p>



<figure class="wp-block-image aligncenter size-full"><img decoding="async" width="660" height="300" src="https://chokomon.com/wp-content/uploads/2022/09/27-06-03-01.png" alt="" class="wp-image-6827"/></figure>



<div class="wp-block-dvaux-frame sc_frame_wrap inline"><div class="sc_frame_title inline" style="background-color:#ccc">問題文</div><div class="sc_frame" style="background-color:#fff;border-color:#ccc">
<p>1 行目に整数 N が与えられます。</p>



<p>2 行目以降に N 個の範囲 [L_i, R_i] (1 ≦ i ≦ N) が整数で N 行で与えられます。</p>



<p>横に並んだ 10 個のマスがあり、最初、マスには全て 0 が書かれています。</p>



<p>それぞれの範囲に対して、その範囲に含まれるマスに 1 を加算していきます。</p>



<p>すべての加算が終わった時点での 10 個のマスに書かれた値のうち、最大の値をいもす法を用いて求めてください。</p>



<p></p>



<p><strong>入力値（例）</strong><br>5<br>1 3<br>1 8<br>3 8<br>3 6<br>7 9</p>



<p><strong>出力値（例）</strong><br>4</p>
</div></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">解答例</h2>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">&lt;?php
    $a = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
    
    $n = trim(fgets(STDIN));
    
    for ($i=0; $i&lt;$n; $i++) {
        list($left, $right) = explode(" ", trim(fgets(STDIN)));
        $l[] = $left;
        $r[] = $right;
        
        $a[$l[$i]-1]++;
        $a[$r[$i]]--;
    }
    
    for ($i=0; $i&lt;11; $i++) {
        if ($i &gt; 0) $a[$i] += $a[$i-1];
    }
    //print_r($a);
    
    echo max($a);
?&gt;</pre></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="160" src="https://chokomon.com/wp-content/uploads/2022/09/27-06-03-02.png" alt="" class="wp-image-6828"/></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://chokomon.com/27-prefix_sum_problems-06-03-00639/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【累積和メニュー】1 次元上のいもす法 2 (paizaランク C)-解答例-PHP編</title>
		<link>https://chokomon.com/27-prefix_sum_problems-06-02-00638/</link>
					<comments>https://chokomon.com/27-prefix_sum_problems-06-02-00638/#respond</comments>
		
		<dc:creator><![CDATA[東鳥子]]></dc:creator>
		<pubDate>Tue, 13 Sep 2022 06:13:51 +0000</pubDate>
				<category><![CDATA[paiza-問題集]]></category>
		<category><![CDATA[累積和メニュー]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ランクC]]></category>
		<category><![CDATA[難易度-1200]]></category>
		<guid isPermaLink="false">https://chokomon.com/?p=6821</guid>

					<description><![CDATA[【累積和メニュー】> 【1 次元上のいもす法】STEP: 2 1 次元上のいもす法 2 (paizaランク C 相当) [難易度: 1209 ±51] ※リンク先へ移動するためには[paiza]へのログインが必要です。 解答例]]></description>
										<content:encoded><![CDATA[
<p>【<a href="https://chokomon.com/paiza_mondai/27-prefix_sum_problems/">累積和メニュー</a>】> <a href="https://paiza.jp/works/mondai/prefix_sum_problems/prefix_sum_problems__1d_imos_step2" target="_blank" rel="noreferrer noopener">【1 次元上のいもす法】STEP: 2 1 次元上のいもす法 2 (paizaランク C 相当)</a> [難易度: <strong>1209 ±51</strong>]



<p>※リンク先へ移動するためには[<a href="https://paiza.jp/works" target="_blank" rel="noreferrer noopener">paiza</a>]へのログインが必要です。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="300" src="https://chokomon.com/wp-content/uploads/2022/09/27-06-02-01.png" alt="" class="wp-image-6822"/></figure>



<div class="wp-block-dvaux-frame sc_frame_wrap inline"><div class="sc_frame_title inline" style="background-color:#ccc">問題文</div><div class="sc_frame" style="background-color:#fff;border-color:#ccc">
<p>1 行目から 5 行目にかけて、5 個の範囲 [L_i, R_i] (1 ≦ i ≦ 5) が整数で与えられます。</p>



<p>横に並んだ 10 個のマスがあり、最初、マスには全て 0 が書かれています。</p>



<p>それぞれの範囲に対して、その範囲に含まれるマスに 1 を加算していきます。</p>



<p>すべての加算が終わった時点での 10 個のマスに書かれた値のうち、最大の値をいもす法を用いて求めてください。</p>



<p></p>



<p><strong>入力値（例）</strong><br>1 3<br>1 8<br>3 8<br>3 6<br>7 9</p>



<p><strong>出力値（例）</strong><br>4</p>
</div></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">解答例</h2>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">&lt;?php
    $a = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
    
    for ($i=0; $i&lt;5; $i++) {
        list($left, $right) = explode(" ", trim(fgets(STDIN)));
        $l[] = $left;
        $r[] = $right;
        
        $a[$l[$i]-1]++;
        $a[$r[$i]]--;
    }
    
    for ($i=0; $i&lt;11; $i++) {
        if ($i &gt; 0) $a[$i] += $a[$i-1];
    }
    //print_r($a);
    
    echo max($a);
?&gt;</pre></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="160" src="https://chokomon.com/wp-content/uploads/2022/09/27-06-02-02.png" alt="" class="wp-image-6823"/></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://chokomon.com/27-prefix_sum_problems-06-02-00638/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【累積和メニュー】【二次元累積和】 二次元累積和 6 (paizaランク C)-解答例-PHP編</title>
		<link>https://chokomon.com/27-prefix_sum_problems-05-06-00635/</link>
					<comments>https://chokomon.com/27-prefix_sum_problems-05-06-00635/#respond</comments>
		
		<dc:creator><![CDATA[東鳥子]]></dc:creator>
		<pubDate>Mon, 12 Sep 2022 01:49:42 +0000</pubDate>
				<category><![CDATA[paiza-問題集]]></category>
		<category><![CDATA[累積和メニュー]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ランクC]]></category>
		<category><![CDATA[難易度-1200]]></category>
		<guid isPermaLink="false">https://chokomon.com/?p=6804</guid>

					<description><![CDATA[【累積和メニュー】> STEP: 6 【二次元累積和】 二次元累積和 6 (paizaランク C 相当) [難易度: 1281 ±50] ※リンク先へ移動するためには[paiza]へのログインが必要です。 解答例]]></description>
										<content:encoded><![CDATA[
<p>【<a href="https://chokomon.com/paiza_mondai/27-prefix_sum_problems/">累積和メニュー</a>】> <a href="https://paiza.jp/works/mondai/prefix_sum_problems/prefix_sum_problems__2dsection_sum_boss1" target="_blank" rel="noreferrer noopener">STEP: 6 【二次元累積和】 二次元累積和 6 (paizaランク C 相当)</a> [難易度: <strong>1281 ±50</strong>]



<p>※リンク先へ移動するためには[<a href="https://paiza.jp/works" target="_blank" rel="noreferrer noopener">paiza</a>]へのログインが必要です。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="300" src="https://chokomon.com/wp-content/uploads/2022/09/27-05-06-01.png" alt="" class="wp-image-6805"/></figure>



<div class="wp-block-dvaux-frame sc_frame_wrap inline"><div class="sc_frame_title inline" style="background-color:#ccc">問題文</div><div class="sc_frame" style="background-color:#fff;border-color:#ccc">
<p>1 行目に整数 N, M が与えられます。</p>



<p>2 行目に整数 a, b, c, d が与えられます。</p>



<p>3 行目以降に N 行 M 列の整数の二次元配列 A が与えられます。</p>



<p>A の i 行目 j 列目を A_{i, j} (0 ≦ i ≦ N - 1, 0 ≦ j ≦ M - 1) と表すことにします。</p>



<p>長方形領域の左上の要素を A_{a, b} 、右下の要素を A_{c, d} としたとき、この長方形領域内の整数の和を累積和を用いて求め、一行で出力してください。</p>



<p></p>



<p><strong>入力値（例）</strong><br>5 5<br>1 1 3 3<br>1 2 3 4 5<br>2 3 4 5 6<br>3 4 5 6 7<br>4 5 6 7 8<br>5 6 7 8 9</p>



<p><strong>出力値（例）</strong><br>45</p>
</div></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">解答例</h2>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">&lt;?php
    list($n, $m) = explode(" ", trim(fgets(STDIN)));
    list($ax, $by, $cx, $dy) = explode(" ", trim(fgets(STDIN)));
    
    for ($i=0; $i&lt;$n; $i++) {
        $a[$i] = explode(" ", trim(fgets(STDIN)));
    }
    //print_r($a);
        
    $sy = $ax; $sx = $by; $ly = $cx; $lx = $dy;
    $h = $n; $w = $m;
    
    $sRow = array_fill(0, $w+1, 0);
    $s = array_fill(0, $h+1, $sRow);
    
    for ($i=0; $i&lt;$h; $i++) {
        for ($j=0; $j&lt;$w; $j++) {
            $s[$i+1][$j+1] = $a[$i][$j]+$s[$i][$j+1]+$s[$i+1][$j]-$s[$i][$j];
        }
    }
    //print_r($s);
    
    $ans = $s[$ly+1][$lx+1]-$s[$sy][$lx+1]-$s[$ly+1][$sx]+$s[$sy][$sx];
    echo $ans;
?&gt;</pre></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="160" src="https://chokomon.com/wp-content/uploads/2022/09/27-05-06-02.png" alt="" class="wp-image-6806"/></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://chokomon.com/27-prefix_sum_problems-05-06-00635/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【累積和メニュー】二次元累積和 5 (paizaランク C)-解答例-PHP編</title>
		<link>https://chokomon.com/27-prefix_sum_problems-05-05-00634/</link>
					<comments>https://chokomon.com/27-prefix_sum_problems-05-05-00634/#respond</comments>
		
		<dc:creator><![CDATA[東鳥子]]></dc:creator>
		<pubDate>Mon, 12 Sep 2022 01:25:06 +0000</pubDate>
				<category><![CDATA[paiza-問題集]]></category>
		<category><![CDATA[累積和メニュー]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ランクC]]></category>
		<category><![CDATA[難易度-1200]]></category>
		<guid isPermaLink="false">https://chokomon.com/?p=6794</guid>

					<description><![CDATA[【累積和メニュー】&#62; 【二次元累積和】STEP: 5 二次元累積和 5(paizaランク C 相当)&#160;[難易度:&#160;1288&#160;±49] ※リンク先へ移動するためには[paiza]へのログインが必要です。 解…]]></description>
										<content:encoded><![CDATA[
<p>【<a href="https://chokomon.com/paiza_mondai/27-prefix_sum_problems/">累積和メニュー</a>】&gt; <a href="https://paiza.jp/works/mondai/prefix_sum_problems/prefix_sum_problems__2dsection_sum_step5" target="_blank" rel="noreferrer noopener">【二次元累積和】STEP: 5 二次元累積和 5(paizaランク C 相当)</a>&nbsp;[難易度:&nbsp;<strong>1288&nbsp;±49</strong>]



<p>※リンク先へ移動するためには[<a href="https://paiza.jp/works" target="_blank" rel="noreferrer noopener">paiza</a>]へのログインが必要です。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="300" src="https://chokomon.com/wp-content/uploads/2022/09/27-05-05-01.png" alt="" class="wp-image-6795"/></figure>



<div class="wp-block-dvaux-frame sc_frame_wrap inline"><div class="sc_frame_title inline" style="background-color:#ccc">問題文</div><div class="sc_frame" style="background-color:#fff;border-color:#ccc">
<p>1 行目に整数 N が与えられます。</p>



<p>2 行目に整数 a, b, c, d が与えられます。</p>



<p>3 行目以降に N 行 N 列の整数の二次元配列 A が与えられます。</p>



<p>A の i 行目 j 列目を A_{i, j} (0 ≦ i ≦ N - 1, 0 ≦ j ≦ N - 1) と表すことにします。</p>



<p>長方形領域の左上の要素を A_{a, b} 、右下の要素を A_{c, d} としたとき、この長方形領域内の整数の和を累積和を用いて求め、一行で出力してください。</p>



<p></p>



<p><strong>入力値（例）</strong><br>5<br>1 1 3 3<br>1 2 3 4 5<br>2 3 4 5 6<br>3 4 5 6 7<br>4 5 6 7 8<br>5 6 7 8 9</p>



<p><strong>出力値（例）</strong><br>45</p>
</div></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">解答例</h2>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">&lt;?php
    $n = trim(fgets(STDIN));
    list($ax, $by, $cx, $dy) = explode(" ", trim(fgets(STDIN)));
    
    for ($i=0; $i&lt;$n; $i++) {
        $a[$i] = explode(" ", trim(fgets(STDIN)));
    }
    //print_r($a);
        
    $sy = $ax; $sx = $by; $ly = $cx; $lx = $dy;
    $h = $n; $w = $n;
    
    $sRow = array_fill(0, $w+1, 0);
    $s = array_fill(0, $h+1, $sRow);
    
    for ($i=0; $i&lt;$h; $i++) {
        for ($j=0; $j&lt;$w; $j++) {
            $s[$i+1][$j+1] = $a[$i][$j]+$s[$i][$j+1]+$s[$i+1][$j]-$s[$i][$j];
        }
    }
    //print_r($s);
    
    $ans = $s[$ly+1][$lx+1]-$s[$sy][$lx+1]-$s[$ly+1][$sx]+$s[$sy][$sx];
    echo $ans;
?&gt;</pre></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="160" src="https://chokomon.com/wp-content/uploads/2022/09/27-05-05-02.png" alt="" class="wp-image-6796"/></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://chokomon.com/27-prefix_sum_problems-05-05-00634/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【累積和メニュー】【区間内の個数 (文字列) 】 区間内の個数 (文字列) 4 (paizaランク C)-解答例-PHP編</title>
		<link>https://chokomon.com/27-prefix_sum_problems-04-04-00629/</link>
					<comments>https://chokomon.com/27-prefix_sum_problems-04-04-00629/#respond</comments>
		
		<dc:creator><![CDATA[東鳥子]]></dc:creator>
		<pubDate>Sat, 10 Sep 2022 19:02:02 +0000</pubDate>
				<category><![CDATA[paiza-問題集]]></category>
		<category><![CDATA[累積和メニュー]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ランクC]]></category>
		<category><![CDATA[難易度-1200]]></category>
		<guid isPermaLink="false">https://chokomon.com/?p=6764</guid>

					<description><![CDATA[【累積和メニュー】> FINAL問題【区間内の個数 (文字列) 】 区間内の個数 (文字列) 4 (paizaランク C 相当) [難易度: 1209 ±39] ※リンク先へ移動するためには[paiza]へのログインが必要です。 解答例]]></description>
										<content:encoded><![CDATA[
<p>【<a href="https://chokomon.com/paiza_mondai/27-prefix_sum_problems/">累積和メニュー</a>】> <a href="https://paiza.jp/works/mondai/prefix_sum_problems/prefix_sum_problems__string_count_boss" target="_blank" rel="noreferrer noopener">FINAL問題【区間内の個数 (文字列) 】 区間内の個数 (文字列) 4 (paizaランク C 相当)</a> [難易度: <strong>1209 ±39</strong>]



<p>※リンク先へ移動するためには[<a href="https://paiza.jp/works" target="_blank" rel="noreferrer noopener">paiza</a>]へのログインが必要です。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="300" src="https://chokomon.com/wp-content/uploads/2022/09/27-04-04-01.png" alt="" class="wp-image-6765"/></figure>



<div class="wp-block-dvaux-frame sc_frame_wrap inline"><div class="sc_frame_title inline" style="background-color:#ccc">問題文</div><div class="sc_frame" style="background-color:#fff;border-color:#ccc">
<p>1 行目に整数 N, X, Y が与えられます。</p>



<p>2 行目に <code><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-light-orange-color">'b'</mark></code> と <code><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-light-orange-color">'w'</mark></code> で構成された長さ N の文字列 str が与えられます。</p>



<p>文字列 str の X 文字目から Y 文字目までの <code><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-light-orange-color">'b'</mark></code> の個数を累積和を用いて求めてください。</p>



<p></p>



<p><strong>入力値（例）</strong><br>10 3 8<br>bwwbwbbwbw</p>



<p><strong>出力値（例）</strong><br>3</p>
</div></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">解答例</h2>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">&lt;?php
    list($n, $x, $y) = explode(" ", trim(fgets(STDIN)));
    $str = trim(fgets(STDIN));
    
    for ($i=0; $i&lt;$n; $i++) {
        ($str[$i] == "b") ? $b[] = 1 : $b[] = 0;
    }
    $s[0] = 0;
    for ($i=0; $i&lt;$n; $i++) {
        $s[$i+1] = $s[$i]+$b[$i];
    }
    //print_r($s);
    echo $s[$y]-$s[$x-1];
?&gt;</pre></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="160" src="https://chokomon.com/wp-content/uploads/2022/09/27-04-04-02.png" alt="" class="wp-image-6766"/></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://chokomon.com/27-prefix_sum_problems-04-04-00629/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【累積和メニュー】【区間内の個数】区間内の個数 4 (paizaランク C)-解答例-PHP編</title>
		<link>https://chokomon.com/27-prefix_sum_problems-03-04-00624/</link>
					<comments>https://chokomon.com/27-prefix_sum_problems-03-04-00624/#respond</comments>
		
		<dc:creator><![CDATA[東鳥子]]></dc:creator>
		<pubDate>Fri, 09 Sep 2022 03:56:51 +0000</pubDate>
				<category><![CDATA[paiza-問題集]]></category>
		<category><![CDATA[累積和メニュー]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ランクC]]></category>
		<category><![CDATA[難易度-1200]]></category>
		<guid isPermaLink="false">https://chokomon.com/?p=6735</guid>

					<description><![CDATA[【累積和メニュー】> FINAL問題【区間内の個数】区間内の個数 4 (paizaランク C 相当) [難易度: 1298 ±33] ※リンク先へ移動するためには[paiza]へのログインが必要です。 解答例]]></description>
										<content:encoded><![CDATA[
<p>【<a href="https://chokomon.com/paiza_mondai/27-prefix_sum_problems/">累積和メニュー</a>】> <a href="https://paiza.jp/works/mondai/prefix_sum_problems/prefix_sum_problems__section_count_boss" target="_blank" rel="noreferrer noopener">FINAL問題【区間内の個数】区間内の個数 4 (paizaランク C 相当)</a> [難易度: <strong>1298 ±33</strong>]



<p>※リンク先へ移動するためには[<a href="https://paiza.jp/works" target="_blank" rel="noreferrer noopener">paiza</a>]へのログインが必要です。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="300" src="https://chokomon.com/wp-content/uploads/2022/09/27-03-04-01.png" alt="" class="wp-image-6736"/></figure>



<div class="wp-block-dvaux-frame sc_frame_wrap inline"><div class="sc_frame_title inline" style="background-color:#ccc">問題文</div><div class="sc_frame" style="background-color:#fff;border-color:#ccc">
<p>1 行目に整数 N, X, Y が与えられます。</p>



<p>2 行目に N 個の整数 a_0, a_1, a_2, ..., a_(N-1) が与えられます。</p>



<p>この数列の a_X から a_Y までの偶数の個数を、累積和を使うことで求め、一行で出力してください。</p>



<p></p>



<p><strong>入力値（例）</strong><br>10 2 7<br>1 2 3 4 5 6 7 8 9 10</p>



<p><strong>出力値（例）</strong><br>3</p>
</div></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">解答例</h2>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">&lt;?php
    list($n, $x, $y) = explode(" ", trim(fgets(STDIN)));
    $a = explode(" ", trim(fgets(STDIN)));
    
    for ($i=0; $i&lt;$n; $i++) {
        ($a[$i] % 2 == 0) ? $b[] = 1 : $b[] = 0;
    }
    $s[0] = 0;
    for ($i=0; $i&lt;$n; $i++) {
        $s[$i+1] = $s[$i]+$b[$i];
    }
    //print_r($s);
    echo $s[$y+1]-$s[$x];
?&gt;</pre></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="160" src="https://chokomon.com/wp-content/uploads/2022/09/27-03-04-02.png" alt="" class="wp-image-6737"/></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://chokomon.com/27-prefix_sum_problems-03-04-00624/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【累積和メニュー】区間内の個数 2 (paizaランク C)-解答例-PHP編</title>
		<link>https://chokomon.com/27-prefix_sum_problems-03-02-00622/</link>
					<comments>https://chokomon.com/27-prefix_sum_problems-03-02-00622/#respond</comments>
		
		<dc:creator><![CDATA[東鳥子]]></dc:creator>
		<pubDate>Fri, 09 Sep 2022 03:20:27 +0000</pubDate>
				<category><![CDATA[paiza-問題集]]></category>
		<category><![CDATA[累積和メニュー]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ランクC]]></category>
		<category><![CDATA[難易度-1200]]></category>
		<guid isPermaLink="false">https://chokomon.com/?p=6723</guid>

					<description><![CDATA[【累積和メニュー】> 【区間内の個数】STEP: 2 区間内の個数 2 (paizaランク C 相当) [難易度: 1233 ±36] ※リンク先へ移動するためには[paiza]へのログインが必要です。 解答例]]></description>
										<content:encoded><![CDATA[
<p>【<a href="https://chokomon.com/paiza_mondai/27-prefix_sum_problems/">累積和メニュー</a>】> <a href="https://paiza.jp/works/mondai/prefix_sum_problems/prefix_sum_problems__section_count_step2" target="_blank" rel="noreferrer noopener">【区間内の個数】STEP: 2 区間内の個数 2 (paizaランク C 相当)</a> [難易度: <strong>1233 ±36</strong>]



<p>※リンク先へ移動するためには[<a href="https://paiza.jp/works" target="_blank" rel="noreferrer noopener">paiza</a>]へのログインが必要です。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="300" src="https://chokomon.com/wp-content/uploads/2022/09/27-03-02-01.png" alt="" class="wp-image-6724"/></figure>



<div class="wp-block-dvaux-frame sc_frame_wrap inline"><div class="sc_frame_title inline" style="background-color:#ccc">問題文</div><div class="sc_frame" style="background-color:#fff;border-color:#ccc">
<p>10 個の整数 a_0, a_1, a_2, ..., a_9 が与えられます。</p>



<p>この数列の a_2 から a_7 までの偶数の個数を、累積和を使うことで求め、一行で出力してください。</p>



<p></p>



<p><strong>入力値（例）</strong><br>1 2 3 4 5 6 7 8 9 10</p>



<p><strong>出力値（例）</strong><br>3</p>
</div></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">解答例</h2>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">&lt;?php
    $a = explode(" ", trim(fgets(STDIN)));
    
    for ($i=0; $i&lt;10; $i++) {
        ($a[$i] % 2 == 0) ? $b[] = 1 : $b[] = 0;
    }
    $s[0] = 0;
    for ($i=0; $i&lt;10; $i++) {
        $s[$i+1] = $s[$i]+$b[$i];
    }
    //print_r($s);
    echo $s[8]-$s[2];
?&gt;</pre></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="160" src="https://chokomon.com/wp-content/uploads/2022/09/27-03-02-02.png" alt="" class="wp-image-6725"/></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://chokomon.com/27-prefix_sum_problems-03-02-00622/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【累積和メニュー】区間内の個数 1 (paizaランク C)-解答例-PHP編</title>
		<link>https://chokomon.com/27-prefix_sum_problems-03-01-00621/</link>
					<comments>https://chokomon.com/27-prefix_sum_problems-03-01-00621/#respond</comments>
		
		<dc:creator><![CDATA[東鳥子]]></dc:creator>
		<pubDate>Fri, 09 Sep 2022 03:08:18 +0000</pubDate>
				<category><![CDATA[paiza-問題集]]></category>
		<category><![CDATA[累積和メニュー]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ランクC]]></category>
		<category><![CDATA[難易度-1200]]></category>
		<guid isPermaLink="false">https://chokomon.com/?p=6718</guid>

					<description><![CDATA[【累積和メニュー】> 【区間内の個数】STEP: 1 区間内の個数 1 (paizaランク C 相当) [難易度: 1246 ±36] ※リンク先へ移動するためには[paiza]へのログインが必要です。 解答例]]></description>
										<content:encoded><![CDATA[
<p>【<a href="https://chokomon.com/paiza_mondai/27-prefix_sum_problems/">累積和メニュー</a>】> <a href="https://paiza.jp/works/mondai/prefix_sum_problems/prefix_sum_problems__section_count_step1" target="_blank" rel="noreferrer noopener">【区間内の個数】STEP: 1 区間内の個数 1 (paizaランク C 相当)</a> [難易度: <strong>1246 ±36</strong>]



<p>※リンク先へ移動するためには[<a href="https://paiza.jp/works" target="_blank" rel="noreferrer noopener">paiza</a>]へのログインが必要です。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="300" src="https://chokomon.com/wp-content/uploads/2022/09/27-03-01-01.png" alt="" class="wp-image-6719"/></figure>



<div class="wp-block-dvaux-frame sc_frame_wrap inline"><div class="sc_frame_title inline" style="background-color:#ccc">問題文</div><div class="sc_frame" style="background-color:#fff;border-color:#ccc">
<p>0 個の整数 a_0, a_1, a_2, ..., a_9 をそれぞれ</p>



<p><code><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-light-orange-color">1 5 9 7 5 3 2 5 8 4</mark></code></p>



<p>としたとき、この数列の a_2 から a_7 までの偶数の個数を、累積和を使うことで求め、一行で出力してください。</p>



<p></p>



<p><strong>入力値（例）</strong><br>なし</p>



<p><strong>出力値（例）</strong><br>与えられた数列の a_2 から a_7 までの偶数の個数を、累積和を使うことで求め、一行で出力してください。</p>



<p>末尾に改行を入れ、余計な文字、空行を含んではいけません。</p>
</div></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">解答例</h2>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">&lt;?php
    $a = [1, 5, 9, 7, 5, 3, 2, 5, 8, 4];
    
    for ($i=0; $i&lt;10; $i++) {
        ($a[$i] % 2 == 0) ? $b[] = 1 : $b[] = 0;
    }
    $s[0] = 0;
    for ($i=0; $i&lt;10; $i++) {
        $s[$i+1] = $s[$i]+$b[$i];
    }
    //print_r($s);
    echo $s[8]-$s[2];
?&gt;</pre></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="160" src="https://chokomon.com/wp-content/uploads/2022/09/27-03-01-02.png" alt="" class="wp-image-6720"/></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://chokomon.com/27-prefix_sum_problems-03-01-00621/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>【累積和メニュー】連続する N 個の和の最大値 3 (paizaランク C)-解答例-PHP編</title>
		<link>https://chokomon.com/27-prefix_sum_problems-02-03-00618/</link>
					<comments>https://chokomon.com/27-prefix_sum_problems-02-03-00618/#respond</comments>
		
		<dc:creator><![CDATA[東鳥子]]></dc:creator>
		<pubDate>Wed, 07 Sep 2022 19:33:08 +0000</pubDate>
				<category><![CDATA[paiza-問題集]]></category>
		<category><![CDATA[累積和メニュー]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[ランクC]]></category>
		<category><![CDATA[難易度-1200]]></category>
		<guid isPermaLink="false">https://chokomon.com/?p=6692</guid>

					<description><![CDATA[【累積和メニュー】&#62; 【連続する N 個の和の最大値】STEP: 3 連続する N 個の和の最大値 3 (paizaランク C 相当)&#160;[難易度:&#160;1232&#160;±33] ※リンク先へ移動するためには[pai…]]></description>
										<content:encoded><![CDATA[
<p>【<a href="https://chokomon.com/paiza_mondai/27-prefix_sum_problems/">累積和メニュー</a>】&gt; <a href="https://paiza.jp/works/mondai/prefix_sum_problems/prefix_sum_problems__sum_max_step3" target="_blank" rel="noreferrer noopener">【連続する N 個の和の最大値】STEP: 3 連続する N 個の和の最大値 3 (paizaランク C 相当)</a>&nbsp;[難易度:&nbsp;<strong>1232&nbsp;±33</strong>]



<p>※リンク先へ移動するためには[<a href="https://paiza.jp/works" target="_blank" rel="noreferrer noopener">paiza</a>]へのログインが必要です。</p>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="300" src="https://chokomon.com/wp-content/uploads/2022/09/27-02-03-01.png" alt="" class="wp-image-6693"/></figure>



<div class="wp-block-dvaux-frame sc_frame_wrap inline"><div class="sc_frame_title inline" style="background-color:#ccc">問題文</div><div class="sc_frame" style="background-color:#fff;border-color:#ccc">
<p>1 行目に整数 N が与えられます。</p>



<p>2 行目に N 個の整数 a_0, a_1, a_2, ..., a_(N-1) が与えられます。</p>



<p>連続する 3 個の整数の和の最大値を、累積和を使うことで求め、一行で出力してください。</p>



<p></p>



<p><strong>入力値（例）</strong><br>10<br>1 2 3 4 5 6 7 8 9 10</p>



<p><strong>出力値（例）</strong><br>27</p>
</div></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<h2 class="wp-block-heading">解答例</h2>



<div class="wp-block-urvanov-syntax-highlighter-code-block"><pre class="urvanov-syntax-highlighter-plain-tag">&lt;?php
    $n = trim(fgets(STDIN));
    $a = explode(" ", trim(fgets(STDIN)));
    
    $sum[0] = 0;
 
    for ($i=0; $i&lt;$n; $i++) {
        $sum[$i+1] = $sum[$i]+$a[$i];
    }
    //print_r($sum);

    $max_sum = 0;
    for ($i=0; $i&lt;($n-3)+1; $i++) {
        $max_sum = max($max_sum, $sum[$i+3]-$sum[$i]);
    }

    echo $max_sum;
?&gt;</pre></div>



<div style="height:30px" aria-hidden="true" class="wp-block-spacer"></div>



<figure class="wp-block-image aligncenter size-full"><img loading="lazy" decoding="async" width="660" height="160" src="https://chokomon.com/wp-content/uploads/2022/09/27-02-03-02.png" alt="" class="wp-image-6694"/></figure>
]]></content:encoded>
					
					<wfw:commentRss>https://chokomon.com/27-prefix_sum_problems-02-03-00618/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
