Submission #1069422

# Submission time Handle Problem Language Result Execution time Memory
1069422 2024-08-21T21:56:36 Z quangminh412 Detecting Molecules (IOI16_molecules) C++14
0 / 100
1 ms 436 KB
#include <bits/stdc++.h>
using namespace std;

/*
  John Watson
  https://codeforces.com/profile/quangminh98

  Mua Code nhu mua Florentino !!
*/

#define faster() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long

vector<int> solve(int l, int u, vector<pair<ll, int>>& p, vector<ll>& pre, int k)
{
	for (int i = k - 1; i < pre.size(); i++)
	{
		ll sum = pre[i] - (i -  k < 0 ? 0 : pre[i - k]);
		if (l <= sum && sum <= u)
		{
			vector<int> ans;
			for (int j = i - k + 1; j <= i; j++)
				ans.push_back(p[j].second);
			return ans;
		}
	}
	return {};
}

vector<int> find_subset(int l, int u, vector<int> w)
{
	int n = w.size();
	vector<pair<ll, int>> p;
	for (int i = 0; i < n; i++)
		p.push_back(make_pair(w[i], i));
	sort(p.begin(), p.end());
	vector<ll> pre(n);
	for (int i = 0; i < n; i++)
		pre[i] = (i == 0 ? 0 : pre[i - 1]) + p[i].first;
	
	for (int i = 1; i <= n; i++)
	{
		if (pre[i - 1] <= u && pre[n - 1] - (n - i - 1 < 0 ? 0 : pre[n - i - 1]) <= l) 
		{
        	vector<int> ans = solve(l, u, p, pre, i);
			if (!ans.empty())
				return ans;  
        }
	}
	
	return {};
}

Compilation message

molecules.cpp: In function 'std::vector<int> solve(int, int, std::vector<std::pair<long long int, int> >&, std::vector<long long int>&, int)':
molecules.cpp:16:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |  for (int i = k - 1; i < pre.size(); i++)
      |                      ~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Correct 0 ms 436 KB OK (n = 1, answer = YES)
4 Correct 0 ms 348 KB OK (n = 2, answer = YES)
5 Correct 1 ms 348 KB OK (n = 2, answer = YES)
6 Correct 0 ms 348 KB OK (n = 3, answer = YES)
7 Correct 0 ms 348 KB OK (n = 3, answer = YES)
8 Correct 0 ms 348 KB OK (n = 3, answer = YES)
9 Correct 1 ms 348 KB OK (n = 3, answer = YES)
10 Correct 0 ms 348 KB OK (n = 3, answer = YES)
11 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Correct 0 ms 436 KB OK (n = 1, answer = YES)
4 Correct 0 ms 348 KB OK (n = 2, answer = YES)
5 Correct 1 ms 348 KB OK (n = 2, answer = YES)
6 Correct 0 ms 348 KB OK (n = 3, answer = YES)
7 Correct 0 ms 348 KB OK (n = 3, answer = YES)
8 Correct 0 ms 348 KB OK (n = 3, answer = YES)
9 Correct 1 ms 348 KB OK (n = 3, answer = YES)
10 Correct 0 ms 348 KB OK (n = 3, answer = YES)
11 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Correct 0 ms 436 KB OK (n = 1, answer = YES)
4 Correct 0 ms 348 KB OK (n = 2, answer = YES)
5 Correct 1 ms 348 KB OK (n = 2, answer = YES)
6 Correct 0 ms 348 KB OK (n = 3, answer = YES)
7 Correct 0 ms 348 KB OK (n = 3, answer = YES)
8 Correct 0 ms 348 KB OK (n = 3, answer = YES)
9 Correct 1 ms 348 KB OK (n = 3, answer = YES)
10 Correct 0 ms 348 KB OK (n = 3, answer = YES)
11 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Correct 0 ms 436 KB OK (n = 1, answer = YES)
4 Correct 0 ms 348 KB OK (n = 2, answer = YES)
5 Correct 1 ms 348 KB OK (n = 2, answer = YES)
6 Correct 0 ms 348 KB OK (n = 3, answer = YES)
7 Correct 0 ms 348 KB OK (n = 3, answer = YES)
8 Correct 0 ms 348 KB OK (n = 3, answer = YES)
9 Correct 1 ms 348 KB OK (n = 3, answer = YES)
10 Correct 0 ms 348 KB OK (n = 3, answer = YES)
11 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Correct 0 ms 436 KB OK (n = 1, answer = YES)
4 Correct 0 ms 348 KB OK (n = 2, answer = YES)
5 Correct 1 ms 348 KB OK (n = 2, answer = YES)
6 Correct 0 ms 348 KB OK (n = 3, answer = YES)
7 Correct 0 ms 348 KB OK (n = 3, answer = YES)
8 Correct 0 ms 348 KB OK (n = 3, answer = YES)
9 Correct 1 ms 348 KB OK (n = 3, answer = YES)
10 Correct 0 ms 348 KB OK (n = 3, answer = YES)
11 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
12 Halted 0 ms 0 KB -