답안 #241181

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
241181 2020-06-23T08:12:28 Z crossing0ver Detecting Molecules (IOI16_molecules) C++17
19 / 100
5 ms 384 KB
#include<bits/stdc++.h>   
//#define int long long 
#include "molecules.h"
using namespace std;
vector<int> answer(deque<int> v) {
	vector<int> ans;
	ans.clear();
	for (int i = 0; i < v.size(); i++) {
		ans.push_back(v[i]);
	}
	return ans;
}
vector<int> find_subset(int l, int u, vector<int> w1) {
	int n = w1.size();
	vector<pair<int,int> > w;
	for (int i = 0; i < w1.size(); i++) w.push_back({w1[i],i});
	sort(w.begin(),w.end());
	long long tot = 0;
	deque<int> v;
	vector<int> ans;
	if (w[0].first > u) return ans;
	for (int i = 0; i < n; i++) {
		if ( tot + 1ll*w[i].first <= u) {
			tot+=1ll*w[i].first;
			v.push_back(w[i].second); 
		}	
	}
	if (tot >= l && tot <= u) return answer(v);

	int in = (v.size() > 0 ? v.back() : -1);
	for (int i = in + 1; i < n; i++) {
		if ( tot + 1ll*w[i].first >= l &&  tot + 1ll*w[i].first <= u) {
			v.push_back(w[i].second);
			return answer(v);
		}
		if (tot + 1ll*w[i].first > u) {
			tot -= 1ll*w[v.front()].first;
			v.pop_front();
		}
		tot += 1ll*w[i].first;
			v.push_back(w[i].second);
		if (tot >= l && tot <= u) return answer(v);
	}
	return ans;
}


        

Compilation message

molecules.cpp: In function 'std::vector<int> answer(std::deque<int>)':
molecules.cpp:8:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < v.size(); i++) {
                  ~~^~~~~~~~~~
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:16:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < w1.size(); i++) w.push_back({w1[i],i});
                  ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB OK (n = 1, answer = NO)
2 Correct 5 ms 256 KB OK (n = 1, answer = NO)
3 Correct 4 ms 384 KB OK (n = 1, answer = YES)
4 Correct 5 ms 384 KB OK (n = 2, answer = YES)
5 Correct 5 ms 256 KB OK (n = 2, answer = YES)
6 Correct 4 ms 384 KB OK (n = 3, answer = YES)
7 Correct 4 ms 256 KB OK (n = 3, answer = YES)
8 Correct 4 ms 256 KB OK (n = 3, answer = YES)
9 Correct 5 ms 256 KB OK (n = 3, answer = YES)
10 Correct 5 ms 256 KB OK (n = 3, answer = YES)
11 Correct 4 ms 256 KB OK (n = 3, answer = YES)
12 Correct 4 ms 256 KB OK (n = 3, answer = YES)
13 Correct 5 ms 256 KB OK (n = 3, answer = NO)
14 Correct 5 ms 256 KB OK (n = 3, answer = YES)
15 Correct 4 ms 256 KB OK (n = 3, answer = YES)
16 Correct 5 ms 256 KB OK (n = 3, answer = NO)
17 Correct 4 ms 256 KB OK (n = 3, answer = NO)
18 Correct 5 ms 384 KB OK (n = 100, answer = NO)
19 Correct 5 ms 256 KB OK (n = 100, answer = YES)
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB OK (n = 12, answer = YES)
2 Correct 4 ms 256 KB OK (n = 12, answer = YES)
3 Correct 4 ms 256 KB OK (n = 12, answer = NO)
4 Correct 5 ms 256 KB OK (n = 12, answer = NO)
5 Correct 5 ms 256 KB OK (n = 12, answer = YES)
6 Correct 5 ms 384 KB OK (n = 12, answer = YES)
7 Correct 5 ms 256 KB OK (n = 12, answer = YES)
8 Correct 5 ms 384 KB OK (n = 12, answer = YES)
9 Correct 5 ms 256 KB OK (n = 6, answer = YES)
10 Correct 4 ms 256 KB OK (n = 12, answer = YES)
11 Correct 4 ms 256 KB OK (n = 100, answer = NO)
12 Correct 5 ms 304 KB OK (n = 100, answer = YES)
13 Correct 5 ms 384 KB OK (n = 100, answer = NO)
14 Correct 5 ms 256 KB OK (n = 100, answer = YES)
15 Correct 4 ms 256 KB OK (n = 100, answer = YES)
16 Correct 5 ms 256 KB OK (n = 100, answer = YES)
17 Correct 5 ms 256 KB OK (n = 100, answer = YES)
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB OK (n = 1, answer = NO)
2 Correct 5 ms 256 KB OK (n = 1, answer = NO)
3 Correct 4 ms 384 KB OK (n = 1, answer = YES)
4 Correct 5 ms 384 KB OK (n = 2, answer = YES)
5 Correct 5 ms 256 KB OK (n = 2, answer = YES)
6 Correct 4 ms 384 KB OK (n = 3, answer = YES)
7 Correct 4 ms 256 KB OK (n = 3, answer = YES)
8 Correct 4 ms 256 KB OK (n = 3, answer = YES)
9 Correct 5 ms 256 KB OK (n = 3, answer = YES)
10 Correct 5 ms 256 KB OK (n = 3, answer = YES)
11 Correct 4 ms 256 KB OK (n = 3, answer = YES)
12 Correct 4 ms 256 KB OK (n = 3, answer = YES)
13 Correct 5 ms 256 KB OK (n = 3, answer = NO)
14 Correct 5 ms 256 KB OK (n = 3, answer = YES)
15 Correct 4 ms 256 KB OK (n = 3, answer = YES)
16 Correct 5 ms 256 KB OK (n = 3, answer = NO)
17 Correct 4 ms 256 KB OK (n = 3, answer = NO)
18 Correct 5 ms 384 KB OK (n = 100, answer = NO)
19 Correct 5 ms 256 KB OK (n = 100, answer = YES)
20 Correct 4 ms 256 KB OK (n = 12, answer = YES)
21 Correct 4 ms 256 KB OK (n = 12, answer = YES)
22 Correct 4 ms 256 KB OK (n = 12, answer = NO)
23 Correct 5 ms 256 KB OK (n = 12, answer = NO)
24 Correct 5 ms 256 KB OK (n = 12, answer = YES)
25 Correct 5 ms 384 KB OK (n = 12, answer = YES)
26 Correct 5 ms 256 KB OK (n = 12, answer = YES)
27 Correct 5 ms 384 KB OK (n = 12, answer = YES)
28 Correct 5 ms 256 KB OK (n = 6, answer = YES)
29 Correct 4 ms 256 KB OK (n = 12, answer = YES)
30 Correct 4 ms 256 KB OK (n = 100, answer = NO)
31 Correct 5 ms 304 KB OK (n = 100, answer = YES)
32 Correct 5 ms 384 KB OK (n = 100, answer = NO)
33 Correct 5 ms 256 KB OK (n = 100, answer = YES)
34 Correct 4 ms 256 KB OK (n = 100, answer = YES)
35 Correct 5 ms 256 KB OK (n = 100, answer = YES)
36 Correct 5 ms 256 KB OK (n = 100, answer = YES)
37 Correct 5 ms 384 KB OK (n = 28, answer = YES)
38 Incorrect 5 ms 256 KB Contestant can not find answer, jury can
39 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB OK (n = 1, answer = NO)
2 Correct 5 ms 256 KB OK (n = 1, answer = NO)
3 Correct 4 ms 384 KB OK (n = 1, answer = YES)
4 Correct 5 ms 384 KB OK (n = 2, answer = YES)
5 Correct 5 ms 256 KB OK (n = 2, answer = YES)
6 Correct 4 ms 384 KB OK (n = 3, answer = YES)
7 Correct 4 ms 256 KB OK (n = 3, answer = YES)
8 Correct 4 ms 256 KB OK (n = 3, answer = YES)
9 Correct 5 ms 256 KB OK (n = 3, answer = YES)
10 Correct 5 ms 256 KB OK (n = 3, answer = YES)
11 Correct 4 ms 256 KB OK (n = 3, answer = YES)
12 Correct 4 ms 256 KB OK (n = 3, answer = YES)
13 Correct 5 ms 256 KB OK (n = 3, answer = NO)
14 Correct 5 ms 256 KB OK (n = 3, answer = YES)
15 Correct 4 ms 256 KB OK (n = 3, answer = YES)
16 Correct 5 ms 256 KB OK (n = 3, answer = NO)
17 Correct 4 ms 256 KB OK (n = 3, answer = NO)
18 Correct 5 ms 384 KB OK (n = 100, answer = NO)
19 Correct 5 ms 256 KB OK (n = 100, answer = YES)
20 Correct 4 ms 256 KB OK (n = 12, answer = YES)
21 Correct 4 ms 256 KB OK (n = 12, answer = YES)
22 Correct 4 ms 256 KB OK (n = 12, answer = NO)
23 Correct 5 ms 256 KB OK (n = 12, answer = NO)
24 Correct 5 ms 256 KB OK (n = 12, answer = YES)
25 Correct 5 ms 384 KB OK (n = 12, answer = YES)
26 Correct 5 ms 256 KB OK (n = 12, answer = YES)
27 Correct 5 ms 384 KB OK (n = 12, answer = YES)
28 Correct 5 ms 256 KB OK (n = 6, answer = YES)
29 Correct 4 ms 256 KB OK (n = 12, answer = YES)
30 Correct 4 ms 256 KB OK (n = 100, answer = NO)
31 Correct 5 ms 304 KB OK (n = 100, answer = YES)
32 Correct 5 ms 384 KB OK (n = 100, answer = NO)
33 Correct 5 ms 256 KB OK (n = 100, answer = YES)
34 Correct 4 ms 256 KB OK (n = 100, answer = YES)
35 Correct 5 ms 256 KB OK (n = 100, answer = YES)
36 Correct 5 ms 256 KB OK (n = 100, answer = YES)
37 Correct 5 ms 384 KB OK (n = 28, answer = YES)
38 Incorrect 5 ms 256 KB Contestant can not find answer, jury can
39 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB OK (n = 1, answer = NO)
2 Correct 5 ms 256 KB OK (n = 1, answer = NO)
3 Correct 4 ms 384 KB OK (n = 1, answer = YES)
4 Correct 5 ms 384 KB OK (n = 2, answer = YES)
5 Correct 5 ms 256 KB OK (n = 2, answer = YES)
6 Correct 4 ms 384 KB OK (n = 3, answer = YES)
7 Correct 4 ms 256 KB OK (n = 3, answer = YES)
8 Correct 4 ms 256 KB OK (n = 3, answer = YES)
9 Correct 5 ms 256 KB OK (n = 3, answer = YES)
10 Correct 5 ms 256 KB OK (n = 3, answer = YES)
11 Correct 4 ms 256 KB OK (n = 3, answer = YES)
12 Correct 4 ms 256 KB OK (n = 3, answer = YES)
13 Correct 5 ms 256 KB OK (n = 3, answer = NO)
14 Correct 5 ms 256 KB OK (n = 3, answer = YES)
15 Correct 4 ms 256 KB OK (n = 3, answer = YES)
16 Correct 5 ms 256 KB OK (n = 3, answer = NO)
17 Correct 4 ms 256 KB OK (n = 3, answer = NO)
18 Correct 5 ms 384 KB OK (n = 100, answer = NO)
19 Correct 5 ms 256 KB OK (n = 100, answer = YES)
20 Correct 4 ms 256 KB OK (n = 12, answer = YES)
21 Correct 4 ms 256 KB OK (n = 12, answer = YES)
22 Correct 4 ms 256 KB OK (n = 12, answer = NO)
23 Correct 5 ms 256 KB OK (n = 12, answer = NO)
24 Correct 5 ms 256 KB OK (n = 12, answer = YES)
25 Correct 5 ms 384 KB OK (n = 12, answer = YES)
26 Correct 5 ms 256 KB OK (n = 12, answer = YES)
27 Correct 5 ms 384 KB OK (n = 12, answer = YES)
28 Correct 5 ms 256 KB OK (n = 6, answer = YES)
29 Correct 4 ms 256 KB OK (n = 12, answer = YES)
30 Correct 4 ms 256 KB OK (n = 100, answer = NO)
31 Correct 5 ms 304 KB OK (n = 100, answer = YES)
32 Correct 5 ms 384 KB OK (n = 100, answer = NO)
33 Correct 5 ms 256 KB OK (n = 100, answer = YES)
34 Correct 4 ms 256 KB OK (n = 100, answer = YES)
35 Correct 5 ms 256 KB OK (n = 100, answer = YES)
36 Correct 5 ms 256 KB OK (n = 100, answer = YES)
37 Correct 5 ms 384 KB OK (n = 28, answer = YES)
38 Incorrect 5 ms 256 KB Contestant can not find answer, jury can
39 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB OK (n = 1, answer = NO)
2 Correct 5 ms 256 KB OK (n = 1, answer = NO)
3 Correct 4 ms 384 KB OK (n = 1, answer = YES)
4 Correct 5 ms 384 KB OK (n = 2, answer = YES)
5 Correct 5 ms 256 KB OK (n = 2, answer = YES)
6 Correct 4 ms 384 KB OK (n = 3, answer = YES)
7 Correct 4 ms 256 KB OK (n = 3, answer = YES)
8 Correct 4 ms 256 KB OK (n = 3, answer = YES)
9 Correct 5 ms 256 KB OK (n = 3, answer = YES)
10 Correct 5 ms 256 KB OK (n = 3, answer = YES)
11 Correct 4 ms 256 KB OK (n = 3, answer = YES)
12 Correct 4 ms 256 KB OK (n = 3, answer = YES)
13 Correct 5 ms 256 KB OK (n = 3, answer = NO)
14 Correct 5 ms 256 KB OK (n = 3, answer = YES)
15 Correct 4 ms 256 KB OK (n = 3, answer = YES)
16 Correct 5 ms 256 KB OK (n = 3, answer = NO)
17 Correct 4 ms 256 KB OK (n = 3, answer = NO)
18 Correct 5 ms 384 KB OK (n = 100, answer = NO)
19 Correct 5 ms 256 KB OK (n = 100, answer = YES)
20 Correct 4 ms 256 KB OK (n = 12, answer = YES)
21 Correct 4 ms 256 KB OK (n = 12, answer = YES)
22 Correct 4 ms 256 KB OK (n = 12, answer = NO)
23 Correct 5 ms 256 KB OK (n = 12, answer = NO)
24 Correct 5 ms 256 KB OK (n = 12, answer = YES)
25 Correct 5 ms 384 KB OK (n = 12, answer = YES)
26 Correct 5 ms 256 KB OK (n = 12, answer = YES)
27 Correct 5 ms 384 KB OK (n = 12, answer = YES)
28 Correct 5 ms 256 KB OK (n = 6, answer = YES)
29 Correct 4 ms 256 KB OK (n = 12, answer = YES)
30 Correct 4 ms 256 KB OK (n = 100, answer = NO)
31 Correct 5 ms 304 KB OK (n = 100, answer = YES)
32 Correct 5 ms 384 KB OK (n = 100, answer = NO)
33 Correct 5 ms 256 KB OK (n = 100, answer = YES)
34 Correct 4 ms 256 KB OK (n = 100, answer = YES)
35 Correct 5 ms 256 KB OK (n = 100, answer = YES)
36 Correct 5 ms 256 KB OK (n = 100, answer = YES)
37 Correct 5 ms 384 KB OK (n = 28, answer = YES)
38 Incorrect 5 ms 256 KB Contestant can not find answer, jury can
39 Halted 0 ms 0 KB -