# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
973716 | NemanjaSo2005 | Detecting Molecules (IOI16_molecules) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>#include "molecules.h"#define ll long longusing namespace std;ll N,zbir;struct slog{ int org,vred;}sniz[5000005];bool cmp(slog a,slog b){ return a.vred<b.vred;}vector<int> find_subset(int L, int R, vector<int> niz){ N=niz.size(); for(int i=1;i<=N;i++){ sniz[i].org=i-1; sniz[i].vred=niz[i-1]; } //sort(sniz+1,sniz+1+N,cmp); int i=1,j=1; zbir=sniz[1].vred; while(j<=N){ if(i>j) break; if(zbir<L){ j++; zbir+=sniz[j].vred; } else if(zbir>R){ zbir-=sniz[i].vred; i++; } if(zbir<=R and zbir>=L){ niz.clear(); for(int k=i;k<=j;k++) niz.push_back(sniz[k].org); return niz; } } niz.clear(); return niz;}