답안 #105481

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
105481 2019-04-12T16:14:00 Z polyfish Detecting Molecules (IOI16_molecules) C++14
0 / 100
3 ms 384 KB
//Pantyhose(black) + glasses = infinity

#include <bits/stdc++.h>
using namespace std;
 
#define debug(x) cerr << #x << " = " << x << '\n';
#define BP() cerr << "OK!\n";
#define PR(A, n) {cerr << #A << " = "; for (int _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; for (int _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define FILE_NAME "data"

vector<int> find_subset(int l, int r, vector<int> w) {
	vector<pair<int, int> > a;

	for (int i=0; i<w.size(); ++i)
		a.push_back({w[i], i});

	sort(a.begin(), a.end());

	for (int i=0, head=-1, cur_sum=0; i<a.size(); ++i) {
		while (head+1<a.size() && cur_sum<l)
			cur_sum += a[++head].first;

		if (cur_sum>=l && cur_sum<=r) {
			vector<int> res;
			for (int j=i; j<=head; ++j)
				res.push_back(a[j].second+1);
			return res;
		}

		cur_sum -= a[i].first;
	}

	return {};
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:15:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0; i<w.size(); ++i)
                ~^~~~~~~~~
molecules.cpp:20:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i=0, head=-1, cur_sum=0; i<a.size(); ++i) {
                                    ~^~~~~~~~~
molecules.cpp:21:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while (head+1<a.size() && cur_sum<l)
          ~~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 256 KB OK (n = 1, answer = NO)
2 Correct 3 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 3 ms 384 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 384 KB OK (n = 12, answer = YES)
2 Correct 3 ms 384 KB OK (n = 12, answer = YES)
3 Correct 2 ms 256 KB OK (n = 12, answer = NO)
4 Correct 3 ms 384 KB OK (n = 12, answer = NO)
5 Incorrect 2 ms 256 KB sum of weights should be in [290..300] but it is 301
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 256 KB OK (n = 1, answer = NO)
2 Correct 3 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 3 ms 384 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 256 KB OK (n = 1, answer = NO)
2 Correct 3 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 3 ms 384 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 256 KB OK (n = 1, answer = NO)
2 Correct 3 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 3 ms 384 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 256 KB OK (n = 1, answer = NO)
2 Correct 3 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 3 ms 384 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -