206272026-01-08 11:36:00szabelrLeggyorsabb pénzkeresés (50)cpp17Wrong answer 2/5030ms1076 KiB
// Leggyorsabb pénzkeresés.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
#include <climits>
using namespace std;
int main()
{
    int n, target;
    cin >> n >> target;
    vector<int>profits(n);
    for (int i = 0; i < n; i++)
    {
        int x; cin >> x;
        profits[i] = x;
    }
    int i = 0;
    int best_size = INT_MAX;
    int cur_sum = 0;
    for (int j = 0; j < n; j++)
    {
        cur_sum += profits[j];
        while (cur_sum >= target and i<j)
        {
            best_size = min(best_size, j - i + 1);
            i++;
        }
    }
    cout << best_size;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
base2/50
1Wrong answer0/01ms316 KiB
2Wrong answer0/029ms564 KiB
3Wrong answer0/21ms316 KiB
4Wrong answer0/21ms316 KiB
5Wrong answer0/21ms316 KiB
6Wrong answer0/24ms316 KiB
7Wrong answer0/24ms316 KiB
8Wrong answer0/24ms316 KiB
9Wrong answer0/24ms560 KiB
10Wrong answer0/24ms316 KiB
11Accepted2/229ms808 KiB
12Wrong answer0/229ms576 KiB
13Wrong answer0/229ms800 KiB
14Wrong answer0/229ms804 KiB
15Wrong answer0/229ms564 KiB
16Wrong answer0/230ms1076 KiB
17Wrong answer0/229ms748 KiB
18Wrong answer0/229ms564 KiB
19Wrong answer0/229ms568 KiB
20Wrong answer0/229ms804 KiB
21Wrong answer0/229ms564 KiB
22Wrong answer0/229ms564 KiB
23Wrong answer0/229ms796 KiB
24Wrong answer0/230ms796 KiB
25Wrong answer0/230ms1076 KiB
26Wrong answer0/229ms564 KiB
27Wrong answer0/229ms564 KiB