238992026-01-31 15:32:20PKBLeghosszabb nyaralás (75 pont)cpp17Wrong answer 0/7526ms800 KiB
// Source: https://usaco.guide/general/io

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

int main() {
    int hossz;
    int leghosszabb;
	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 && hossz >= leghosszabb){
            leghosszabb = hossz;
        }
        if(mostani < penz){
            hossz++;
            mostani+= szamok[i];
            i++;
        }else{
            j++;
            hossz--;
            mostani-= szamok[j-1];
        }
    }
    cout << leghosszabb;
}
SubtaskSumTestVerdictTimeMemory
base0/75
1Wrong answer0/01ms316 KiB
2Wrong answer0/026ms564 KiB
3Wrong answer0/31ms316 KiB
4Wrong answer0/31ms500 KiB
5Wrong answer0/31ms316 KiB
6Wrong answer0/31ms316 KiB
7Wrong answer0/31ms356 KiB
8Wrong answer0/41ms316 KiB
9Wrong answer0/41ms316 KiB
10Wrong answer0/51ms316 KiB
11Wrong answer0/53ms316 KiB
12Wrong answer0/54ms332 KiB
13Wrong answer0/718ms564 KiB
14Wrong answer0/723ms564 KiB
15Wrong answer0/726ms800 KiB
16Wrong answer0/825ms564 KiB
17Wrong answer0/826ms564 KiB