| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 137115 | anayk | Detecting Molecules (IOI16_molecules) | C++14 | 64 ms | 6620 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "molecules.h"
#include <vector>
#include <algorithm>
#include <iostream>
#define MAXN 200005
int n;
std::vector<int> answer;
bool choice[MAXN];
std::pair<int, int> vals[MAXN];
int rev[MAXN];
void make()
{
	for(int i = 0; i < n; i++)
		if(choice[i])
			answer.push_back(rev[i]);
}
std::vector<int> find_subset(int l, int u, std::vector<int> w)
{
	n = w.size();
	
	for(int i = 0; i < n; i++)
	{
		vals[i].first = w[i];
		vals[i].second = i;
		choice[i] = false;
	}
	
	std::sort(vals, vals+n);
	
	for(int i = 0; i < n; i++)
	{
		w[i] = vals[i].first;
		rev[i] = vals[i].second;
	}
	
	long long cur = 0;
	long long low = 0; long long high = 0;
	bool poss = false;
	for(int i = 0; i < n; i++)
	{
		low += w[i];
		high += w[n-1-i];
		cur += w[n-1-i];
		choice[n-1-i] = true;
		
		if(high >= l && low <= u)
		{
			poss = true;
			break;
		}
	}
	
	if(!poss)
		return answer;
	
	if(cur <= u)
	{
		make();
		return answer;
	}
	
	int x = 0; int y = n-1;
	while(x < n)
	{
		if(choice[x])
		{
			x++;
			continue;
		}
		
		if(!choice[y])
		{
			y--;
			continue;
		}
		
		choice[x] = true;
		choice[y] = false;
		
		cur += w[x] - w[y];
		
		if(cur <= u)
		{
			make();
			return answer;
		}
	}
}
int ma1n()
{
	int l, u;
	std::cin >> n >> l >> u;
	
	std::vector<int> w(n);
	for(int i = 0; i < n; i++)
		std::cin >> w[i];
	
	find_subset(l, u, w);
	
	std::cout << answer.size() << std::endl;
	for(int j = 0; j < answer.size(); j++)
		std::cout << answer[j] << " ";
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
