답안 #132448

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
132448 2019-07-18T20:52:20 Z bogdan10bos Detecting Molecules (IOI16_molecules) C++14
9 / 100
3 ms 380 KB
/// 00:00 , should I call ?
#include "molecules.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long LL;

vector<int> find_subset(int l, int u, vector<int> w)
{
	vector<int> ord;
	for(int i = 0; i < w.size(); i++)	ord.push_back(i);
	sort(ord.begin(), ord.end(),
			[&](int a, int b) { return w[a] < w[b]; } );

	vector<LL> sum(w.size());
	LL s = 0;
	for(int i = 0; i < w.size(); i++)
	{
		s += w[ ord[i] ];
		sum[i] = s;
	}

	vector<int> ans;
	for(int i = 0; i < w.size(); i++)
		if(l <= sum[i] && sum[i] <= u)
		{
			for(int j = 0; j <= i; j++)	ans.push_back(ord[j]);
			sort(ans.begin(), ans.end());
			return ans;
		}
	for(int i = 0; i < w.size(); i++)
			if(l <= s - sum[i] && s - sum[i] <= u)
			{
				for(int j = (int)w.size() - 1; j > i; j--)	ans.push_back(ord[j]);
				sort(ans.begin(), ans.end());
				return ans;
			}
	if(l <= s && s <= u)
	{
		sort(ord.begin(), ord.end());
		return ord;

	}

	return ans;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:12:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < w.size(); i++) ord.push_back(i);
                 ~~^~~~~~~~~~
molecules.cpp:18:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < w.size(); i++)
                 ~~^~~~~~~~~~
molecules.cpp:25:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < w.size(); i++)
                 ~~^~~~~~~~~~
molecules.cpp:32:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < w.size(); i++)
                 ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Correct 2 ms 256 KB OK (n = 1, answer = YES)
4 Correct 2 ms 256 KB OK (n = 2, answer = YES)
5 Correct 2 ms 348 KB OK (n = 2, answer = YES)
6 Correct 2 ms 376 KB OK (n = 3, answer = YES)
7 Correct 2 ms 376 KB OK (n = 3, answer = YES)
8 Correct 2 ms 376 KB OK (n = 3, answer = YES)
9 Correct 2 ms 256 KB OK (n = 3, answer = YES)
10 Correct 2 ms 376 KB OK (n = 3, answer = YES)
11 Correct 2 ms 376 KB OK (n = 3, answer = YES)
12 Correct 2 ms 380 KB OK (n = 3, answer = YES)
13 Correct 2 ms 376 KB OK (n = 3, answer = NO)
14 Correct 2 ms 376 KB OK (n = 3, answer = YES)
15 Correct 2 ms 376 KB OK (n = 3, answer = YES)
16 Correct 2 ms 252 KB OK (n = 3, answer = NO)
17 Correct 2 ms 376 KB OK (n = 3, answer = NO)
18 Correct 2 ms 256 KB OK (n = 100, answer = NO)
19 Correct 2 ms 252 KB OK (n = 100, answer = YES)
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 256 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Correct 2 ms 256 KB OK (n = 1, answer = YES)
4 Correct 2 ms 256 KB OK (n = 2, answer = YES)
5 Correct 2 ms 348 KB OK (n = 2, answer = YES)
6 Correct 2 ms 376 KB OK (n = 3, answer = YES)
7 Correct 2 ms 376 KB OK (n = 3, answer = YES)
8 Correct 2 ms 376 KB OK (n = 3, answer = YES)
9 Correct 2 ms 256 KB OK (n = 3, answer = YES)
10 Correct 2 ms 376 KB OK (n = 3, answer = YES)
11 Correct 2 ms 376 KB OK (n = 3, answer = YES)
12 Correct 2 ms 380 KB OK (n = 3, answer = YES)
13 Correct 2 ms 376 KB OK (n = 3, answer = NO)
14 Correct 2 ms 376 KB OK (n = 3, answer = YES)
15 Correct 2 ms 376 KB OK (n = 3, answer = YES)
16 Correct 2 ms 252 KB OK (n = 3, answer = NO)
17 Correct 2 ms 376 KB OK (n = 3, answer = NO)
18 Correct 2 ms 256 KB OK (n = 100, answer = NO)
19 Correct 2 ms 252 KB OK (n = 100, answer = YES)
20 Incorrect 3 ms 256 KB Contestant can not find answer, jury can
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Correct 2 ms 256 KB OK (n = 1, answer = YES)
4 Correct 2 ms 256 KB OK (n = 2, answer = YES)
5 Correct 2 ms 348 KB OK (n = 2, answer = YES)
6 Correct 2 ms 376 KB OK (n = 3, answer = YES)
7 Correct 2 ms 376 KB OK (n = 3, answer = YES)
8 Correct 2 ms 376 KB OK (n = 3, answer = YES)
9 Correct 2 ms 256 KB OK (n = 3, answer = YES)
10 Correct 2 ms 376 KB OK (n = 3, answer = YES)
11 Correct 2 ms 376 KB OK (n = 3, answer = YES)
12 Correct 2 ms 380 KB OK (n = 3, answer = YES)
13 Correct 2 ms 376 KB OK (n = 3, answer = NO)
14 Correct 2 ms 376 KB OK (n = 3, answer = YES)
15 Correct 2 ms 376 KB OK (n = 3, answer = YES)
16 Correct 2 ms 252 KB OK (n = 3, answer = NO)
17 Correct 2 ms 376 KB OK (n = 3, answer = NO)
18 Correct 2 ms 256 KB OK (n = 100, answer = NO)
19 Correct 2 ms 252 KB OK (n = 100, answer = YES)
20 Incorrect 3 ms 256 KB Contestant can not find answer, jury can
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Correct 2 ms 256 KB OK (n = 1, answer = YES)
4 Correct 2 ms 256 KB OK (n = 2, answer = YES)
5 Correct 2 ms 348 KB OK (n = 2, answer = YES)
6 Correct 2 ms 376 KB OK (n = 3, answer = YES)
7 Correct 2 ms 376 KB OK (n = 3, answer = YES)
8 Correct 2 ms 376 KB OK (n = 3, answer = YES)
9 Correct 2 ms 256 KB OK (n = 3, answer = YES)
10 Correct 2 ms 376 KB OK (n = 3, answer = YES)
11 Correct 2 ms 376 KB OK (n = 3, answer = YES)
12 Correct 2 ms 380 KB OK (n = 3, answer = YES)
13 Correct 2 ms 376 KB OK (n = 3, answer = NO)
14 Correct 2 ms 376 KB OK (n = 3, answer = YES)
15 Correct 2 ms 376 KB OK (n = 3, answer = YES)
16 Correct 2 ms 252 KB OK (n = 3, answer = NO)
17 Correct 2 ms 376 KB OK (n = 3, answer = NO)
18 Correct 2 ms 256 KB OK (n = 100, answer = NO)
19 Correct 2 ms 252 KB OK (n = 100, answer = YES)
20 Incorrect 3 ms 256 KB Contestant can not find answer, jury can
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Correct 2 ms 256 KB OK (n = 1, answer = YES)
4 Correct 2 ms 256 KB OK (n = 2, answer = YES)
5 Correct 2 ms 348 KB OK (n = 2, answer = YES)
6 Correct 2 ms 376 KB OK (n = 3, answer = YES)
7 Correct 2 ms 376 KB OK (n = 3, answer = YES)
8 Correct 2 ms 376 KB OK (n = 3, answer = YES)
9 Correct 2 ms 256 KB OK (n = 3, answer = YES)
10 Correct 2 ms 376 KB OK (n = 3, answer = YES)
11 Correct 2 ms 376 KB OK (n = 3, answer = YES)
12 Correct 2 ms 380 KB OK (n = 3, answer = YES)
13 Correct 2 ms 376 KB OK (n = 3, answer = NO)
14 Correct 2 ms 376 KB OK (n = 3, answer = YES)
15 Correct 2 ms 376 KB OK (n = 3, answer = YES)
16 Correct 2 ms 252 KB OK (n = 3, answer = NO)
17 Correct 2 ms 376 KB OK (n = 3, answer = NO)
18 Correct 2 ms 256 KB OK (n = 100, answer = NO)
19 Correct 2 ms 252 KB OK (n = 100, answer = YES)
20 Incorrect 3 ms 256 KB Contestant can not find answer, jury can
21 Halted 0 ms 0 KB -