<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.universitas.ro/index.php?action=history&amp;feed=atom&amp;title=2443_-_Cb2</id>
	<title>2443 - Cb2 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.universitas.ro/index.php?action=history&amp;feed=atom&amp;title=2443_-_Cb2"/>
	<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=2443_-_Cb2&amp;action=history"/>
	<updated>2026-05-01T06:47:57Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.42.1</generator>
	<entry>
		<id>https://wiki.universitas.ro/index.php?title=2443_-_Cb2&amp;diff=7736&amp;oldid=prev</id>
		<title>Raul: Pagină nouă: Se consideră un șir de numere naturale nenule &lt;code&gt;a[1]&lt;/code&gt;, &lt;code&gt;a[2]&lt;/code&gt;, …, &lt;code&gt;a[n]&lt;/code&gt;. Asupra șirului se efectuează &lt;code&gt;Q&lt;/code&gt; interogări. Fiecare interogare este dată de o pereche &lt;code&gt;(x, s)&lt;/code&gt;: care este indicele maxim &lt;code&gt;p&lt;/code&gt; cu proprietatea că &lt;code&gt;a[i] ≤ x&lt;/code&gt;, pentru orice &lt;code&gt;i=1..p&lt;/code&gt; și în plus &lt;code&gt;a[1] + a[2] + ... + a[p] ≤ s&lt;/code&gt;?  = Cerința = Trebuie să răspundeți la fiecare din cele &lt;code&gt;Q&lt;/cod...</title>
		<link rel="alternate" type="text/html" href="https://wiki.universitas.ro/index.php?title=2443_-_Cb2&amp;diff=7736&amp;oldid=prev"/>
		<updated>2023-12-10T13:19:08Z</updated>

		<summary type="html">&lt;p&gt;Pagină nouă: Se consideră un șir de numere naturale nenule &amp;lt;code&amp;gt;a[1]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;a[2]&amp;lt;/code&amp;gt;, …, &amp;lt;code&amp;gt;a[n]&amp;lt;/code&amp;gt;. Asupra șirului se efectuează &amp;lt;code&amp;gt;Q&amp;lt;/code&amp;gt; interogări. Fiecare interogare este dată de o pereche &amp;lt;code&amp;gt;(x, s)&amp;lt;/code&amp;gt;: care este indicele maxim &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; cu proprietatea că &amp;lt;code&amp;gt;a[i] ≤ x&amp;lt;/code&amp;gt;, pentru orice &amp;lt;code&amp;gt;i=1..p&amp;lt;/code&amp;gt; și în plus &amp;lt;code&amp;gt;a[1] + a[2] + ... + a[p] ≤ s&amp;lt;/code&amp;gt;?  = Cerința = Trebuie să răspundeți la fiecare din cele &amp;lt;code&amp;gt;Q&amp;lt;/cod...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Se consideră un șir de numere naturale nenule &amp;lt;code&amp;gt;a[1]&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;a[2]&amp;lt;/code&amp;gt;, …, &amp;lt;code&amp;gt;a[n]&amp;lt;/code&amp;gt;. Asupra șirului se efectuează &amp;lt;code&amp;gt;Q&amp;lt;/code&amp;gt; interogări. Fiecare interogare este dată de o pereche &amp;lt;code&amp;gt;(x, s)&amp;lt;/code&amp;gt;: care este indicele maxim &amp;lt;code&amp;gt;p&amp;lt;/code&amp;gt; cu proprietatea că &amp;lt;code&amp;gt;a[i] ≤ x&amp;lt;/code&amp;gt;, pentru orice &amp;lt;code&amp;gt;i=1..p&amp;lt;/code&amp;gt; și în plus &amp;lt;code&amp;gt;a[1] + a[2] + ... + a[p] ≤ s&amp;lt;/code&amp;gt;?&lt;br /&gt;
&lt;br /&gt;
= Cerința =&lt;br /&gt;
Trebuie să răspundeți la fiecare din cele &amp;lt;code&amp;gt;Q&amp;lt;/code&amp;gt; întrebări.&lt;br /&gt;
&lt;br /&gt;
= Date de intrare =&lt;br /&gt;
Programul citește de la tastatură numărul &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt;, iar apoi &amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt; numere naturale, separate prin spații, reprezentând elementele șirului. Apoi se citește valoarea &amp;lt;code&amp;gt;Q&amp;lt;/code&amp;gt; și la final se citesc &amp;lt;code&amp;gt;Q&amp;lt;/code&amp;gt; perechi de forma &amp;lt;code&amp;gt;(x, s)&amp;lt;/code&amp;gt; reprezentând întrebările.&lt;br /&gt;
&lt;br /&gt;
= Date de ieșire =&lt;br /&gt;
Programul va afișa pe câte o linie la ecran &amp;lt;code&amp;gt;Q&amp;lt;/code&amp;gt; valori reprezentând răspunsurile la întrebări.&lt;br /&gt;
&lt;br /&gt;
= Restricții și precizări =&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;1 ≤ n ≤ 100.000&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;1 ≤ Q ≤ 100.000&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;1 ≤ a[i] ≤ 1.000&amp;lt;/code&amp;gt; pentru orice &amp;lt;code&amp;gt;i=1..n&amp;lt;/code&amp;gt;&lt;br /&gt;
* pentru fiecare întrebare, &amp;lt;code&amp;gt;1 ≤ x, s ≤ 1.000.000.000&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Exemplu: =&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Intrare&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 9&lt;br /&gt;
 5 3 1 7 4 9 8 2 6&lt;br /&gt;
 6&lt;br /&gt;
 8 10&lt;br /&gt;
 4 20&lt;br /&gt;
 6 20&lt;br /&gt;
 6 8&lt;br /&gt;
 10 100&lt;br /&gt;
 10 20&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Ieșire&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
 3&lt;br /&gt;
 0&lt;br /&gt;
 3&lt;br /&gt;
 2&lt;br /&gt;
 9&lt;br /&gt;
 5&lt;br /&gt;
&lt;br /&gt;
=== Explicație ===&lt;br /&gt;
La prima întrebare, &amp;lt;code&amp;gt;x=8&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;s=10&amp;lt;/code&amp;gt;. Indicele maxim este &amp;lt;code&amp;gt;3&amp;lt;/code&amp;gt; pentru că primele trei valori din șir sunt mai mici sau egale cu &amp;lt;code&amp;gt;8&amp;lt;/code&amp;gt;, iar &amp;lt;code&amp;gt;5 + 3 + 1 ≤ 10&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
La a doua întrebare, răspunsul este &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; deoarece primul număr din șir este &amp;lt;code&amp;gt;5&amp;lt;/code&amp;gt; care este mai mare decât &amp;lt;code&amp;gt;x=4&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
La a cincea întrebare, &amp;lt;code&amp;gt;x=10&amp;lt;/code&amp;gt; și &amp;lt;code&amp;gt;s=100&amp;lt;/code&amp;gt;. Răspunsul este chiar lungimea șirului.&lt;br /&gt;
&lt;br /&gt;
== Încărcare soluție ==&lt;br /&gt;
&lt;br /&gt;
=== Lipește codul aici ===&lt;br /&gt;
1&lt;br /&gt;
 ​let a;&lt;br /&gt;
&lt;br /&gt;
 let s = 0;&lt;br /&gt;
&lt;br /&gt;
 let i = 1;&lt;br /&gt;
&lt;br /&gt;
 a = prompt();&lt;br /&gt;
&lt;br /&gt;
 s += a.charCodeAt(0);&lt;br /&gt;
&lt;br /&gt;
 while (a !== &amp;#039;.&amp;#039;) {&lt;br /&gt;
&lt;br /&gt;
     a = prompt();&lt;br /&gt;
&lt;br /&gt;
     if (a === &amp;#039;.&amp;#039;) {&lt;br /&gt;
&lt;br /&gt;
         break;&lt;br /&gt;
&lt;br /&gt;
     } else {&lt;br /&gt;
&lt;br /&gt;
         s += a.charCodeAt(0);&lt;br /&gt;
&lt;br /&gt;
         i++;&lt;br /&gt;
&lt;br /&gt;
     }&lt;br /&gt;
&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 console.log(String.fromCharCode(Math.floor(s / i)));&lt;/div&gt;</summary>
		<author><name>Raul</name></author>
	</entry>
</feed>