답안 #1069051

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1069051 2024-08-21T15:16:38 Z quangminh412 Detecting Molecules (IOI16_molecules) C++14
0 / 100
1000 ms 348 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;
	
	int i = 1, j = n;
	while (i != j)
	{
		int mid = i + j >> 1;
		
		vector<int> tmp = solve(l, u, p, pre, mid);
		if (tmp.empty())
			i = j + 1;
		else
			return tmp;
	}
	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++)
      |                      ~~^~~~~~~~~~~~
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:44:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   44 |   int mid = i + j >> 1;
      |             ~~^~~
# 결과 실행 시간 메모리 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 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB OK (n = 12, answer = YES)
2 Correct 0 ms 348 KB OK (n = 12, answer = YES)
3 Execution timed out 1028 ms 348 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 Incorrect 0 ms 348 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -