Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- //using System.IO;
- namespace munka
- {
- class Program
- {
- static void Main(string[] args)
- {
- //StreamReader be = new StreamReader("in.5");
- //Console.SetIn(be);
- string[] line = Console.ReadLine().Split(' ');
- int N = int.Parse(line[0]);
- int F = int.Parse(line[1]);
- int sumF = 0;
- int temp_tol = 0, temp_ig = 0;
- int cnt2 = 0;
- int jo_tol = -1;
- int jo_ig = 0;
- int cnt = 0;
- int legkevesebb = -1;
- List<int> jov = new List<int>();
- for (int i=0; i<N; i++)
- jov.Add(int.Parse(Console.ReadLine()));
- jov.Add(0);
- //be.Close();
- bool done = false;
- //StreamWriter ki = new StreamWriter("ki.txt");
- //Console.SetOut(ki);
- while (cnt < N)
- {
- while (cnt2 < N && done == false)
- {
- sumF += jov[cnt2];
- if (sumF >= F)
- {
- done = true;
- temp_tol = cnt;
- temp_ig = cnt2;
- if (legkevesebb == -1 || cnt2 - cnt < legkevesebb)
- {
- jo_tol = temp_tol;
- jo_ig = temp_ig;
- legkevesebb = jo_ig - jo_tol;
- }
- }
- cnt2++;
- }
- cnt++;
- cnt2 = cnt;
- done = false;
- sumF = 0;
- }
- if (jo_tol == -1)
- Console.WriteLine("{0} {1}", -1, -1);
- else
- Console.WriteLine("{0} {1}", jo_tol+1, jo_ig+1);
- //ki.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment