Submission #373516

#TimeUsernameProblemLanguageResultExecution timeMemory
373516flappybirdDetecting Molecules (IOI16_molecules)C++14
100 / 100
66 ms7148 KiB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MAX 505050
#define pb push_back
ll arr[MAX];
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
	vector<pair<ll, int>> vv;
	vv.resize(w.size() + 1);
	ll i;
	vv[0].second = -1;
	for (i = 0; i < w.size(); i++) {
		vv[i + 1] = { w[i], i };
	}
	sort(vv.begin(), vv.end());
	for (i = 1; i < w.size(); i++) {
		vv[i + 1].first += vv[i].first;
	}
	ll low, high;
	low = 1, high = 1;
	vector<int> ret;
	bool c = false;
	while (1) {
		if (high > w.size()) break;
		ll x = vv[high].first - vv[low - 1].first;
		if ((ll)l <= x && x <= (ll)u) {
			for (i = low; i <= high; i++) ret.push_back(vv[i].second);
			c = true;
			break;
		}
		if (x < (ll)l) high++;
		if (x > (ll)u) low++;
	}
	return ret;
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:13:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |  for (i = 0; i < w.size(); i++) {
      |              ~~^~~~~~~~~~
molecules.cpp:17:16: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for (i = 1; i < w.size(); i++) {
      |              ~~^~~~~~~~~~
molecules.cpp:25:12: warning: comparison of integer expressions of different signedness: 'll' {aka 'long long int'} and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   if (high > w.size()) break;
      |       ~~~~~^~~~~~~~~~
molecules.cpp:23:7: warning: variable 'c' set but not used [-Wunused-but-set-variable]
   23 |  bool c = false;
      |       ^
#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...