Submission #128098

#TimeUsernameProblemLanguageResultExecution timeMemory
128098ekremDetecting Molecules (IOI16_molecules)C++98
100 / 100
82 ms6380 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;
vector < ii > x;

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

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++)
                 ~~^~~~~~~~~~
molecules.cpp:31: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...