94372024-02-21 17:32:43Vkrisztian01Ládapakolás raktárban (50)cpp11Accepted 50/5052ms8208 KiB
#include <iostream>
#include<vector>
#include<set>

using namespace std;


int n,m,akt,elozo=0,osszeg=0,db=0;
bool emelkedik=true;
set<int>seged;

int main()
{
   cin>>n>>m;
   for(int i=1;i<=n;i++)
   {
       cin>>akt;
       if(osszeg+akt>m || seged.count(akt) || (!emelkedik && elozo<akt))
       {
           ++db;
           osszeg=0;
           seged.clear();
           emelkedik=true;
       }
       else
       {
           if(akt<elozo) emelkedik=false;
       }
       seged.insert(akt);
       osszeg+=akt;
       elozo=akt;
   }
   ++db;
   cout<<n-db;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1748 KiB
2Accepted0/06ms1992 KiB
3Accepted2/23ms2232 KiB
4Accepted2/23ms2472 KiB
5Accepted2/23ms2688 KiB
6Accepted2/23ms2776 KiB
7Accepted2/23ms2688 KiB
8Accepted2/23ms2912 KiB
9Accepted3/33ms3120 KiB
10Accepted2/23ms3256 KiB
11Accepted2/23ms3204 KiB
12Accepted2/23ms3324 KiB
13Accepted3/34ms3288 KiB
14Accepted3/34ms3428 KiB
15Accepted3/36ms3632 KiB
16Accepted2/232ms3876 KiB
17Accepted3/341ms3816 KiB
18Accepted3/352ms3908 KiB
19Accepted3/337ms4180 KiB
20Accepted3/350ms7360 KiB
21Accepted3/346ms7572 KiB
22Accepted3/350ms8208 KiB