239002026-01-31 15:42:06PKBLeghosszabb nyaralás (75 pont)cpp17Wrong answer 58/7526ms756 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

int main() {
    int hossz = 0;
    int leghosszabb = 0;
	int N;
    cin >> N;
    int penz;
    cin >> penz;
    int i = 0; int j = 0;
    int mostani = 0;
    vector<int>szamok(N);
    for(int h = 0; h < N; h++){
        cin >> szamok[h];
    }
    while (j < N && i < N) {
        if(mostani <= penz && i - j >= leghosszabb){
            leghosszabb = i - j;
        }
        if(mostani <= penz){
            mostani+= szamok[i];
            i++;
        }else{   
            mostani-= szamok[j];
            j++;
        }
    }
    cout << leghosszabb;
}
SubtaskSumTestVerdictTimeMemory
base58/75
1Accepted0/01ms512 KiB
2Accepted0/026ms564 KiB
3Accepted3/31ms316 KiB
4Wrong answer0/31ms316 KiB
5Accepted3/31ms500 KiB
6Wrong answer0/31ms316 KiB
7Accepted3/31ms316 KiB
8Wrong answer0/41ms316 KiB
9Accepted4/41ms500 KiB
10Accepted5/51ms384 KiB
11Accepted5/53ms316 KiB
12Accepted5/54ms508 KiB
13Wrong answer0/718ms748 KiB
14Accepted7/721ms756 KiB
15Accepted7/726ms564 KiB
16Accepted8/825ms564 KiB
17Accepted8/826ms564 KiB