Submission #128092

#TimeUsernameProblemLanguageResultExecution timeMemory
128092ekremDetecting Molecules (IOI16_molecules)C++98
9 / 100
2 ms404 KiB
#include "molecules.h"
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1000000009
#define N 1000005
using namespace std;

typedef long long ll;
typedef pair < int , int > ii;
typedef vector < int > vi;

int n;

vi find_subset(int l, int u, vi w) {
	sort(w.begin(), w.end());
	ll top = 0, bas = 0;
	for(int i = 0; i < w.size(); i++){
		top += w[i];
		while(top > u){
			top -= w[bas];
			bas++;
		}
		if(top >= l and top <= u){
			vi ans;
			for(int j = bas; j <= i; j++)
				ans.pb(j);
			return ans;
		}
	}
    return vi(0);
}

Compilation message (stderr)

molecules.cpp: In function 'vi find_subset(int, int, vi)':
molecules.cpp:25:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < w.size(); i++){
                 ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...