답안 #223726

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
223726 2020-04-16T08:42:59 Z bharat2002 Detecting Molecules (IOI16_molecules) C++14
9 / 100
5 ms 384 KB
#include "molecules.h"
#include<bits/stdc++.h>
using namespace std;
const int N=2e5 + 100;
const int mod=1e9 + 7;
#define pii pair<int, int>
#define mp make_pair
#define f first
#define s second
int n;vector< pii > vals;
bool sf(pii a, pii b);
vector<int> find_subset(int l, int u, vector<int> w)
{
	vector<int> ans;
	n=w.size();
	for(int i=0;i<w.size();i++)
	{
		vals.push_back(mp(w[i], i));
	}
	sort(vals.begin(), vals.end(), sf);
	int mval=vals.back().f;
	for(auto &i:vals) i.f-=mval;
	if(mval>u) return ans;
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		sum+=vals[i-1].f;
		if(i*mval + sum>u)
		{
			if(i*mval + sum - vals[0].f<=u)
			{
				for(int j=1;j<i;j++) ans.push_back(vals[j].s);
				ans.push_back(vals.back().s);break;
			}
		}
		else if(i*mval+sum>=l)
		{
			for(int j=0;j<i;j++) ans.push_back(vals[j].s);break;
		}
	}
	return ans;
}
bool sf(pii a, pii b)
{
	return a.f>b.f;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:16:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<w.size();i++)
              ~^~~~~~~~~
molecules.cpp:38:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
    for(int j=0;j<i;j++) ans.push_back(vals[j].s);break;
    ^~~
molecules.cpp:38:50: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
    for(int j=0;j<i;j++) ans.push_back(vals[j].s);break;
                                                  ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB OK (n = 1, answer = NO)
2 Correct 4 ms 384 KB OK (n = 1, answer = NO)
3 Correct 4 ms 256 KB OK (n = 1, answer = YES)
4 Correct 4 ms 256 KB OK (n = 2, answer = YES)
5 Correct 5 ms 256 KB OK (n = 2, answer = YES)
6 Correct 4 ms 256 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 384 KB OK (n = 3, answer = YES)
10 Correct 4 ms 256 KB OK (n = 3, answer = YES)
11 Correct 4 ms 256 KB OK (n = 3, answer = YES)
12 Correct 5 ms 384 KB OK (n = 3, answer = YES)
13 Correct 5 ms 256 KB OK (n = 3, answer = NO)
14 Correct 4 ms 256 KB OK (n = 3, answer = YES)
15 Correct 4 ms 256 KB OK (n = 3, answer = YES)
16 Correct 4 ms 256 KB OK (n = 3, answer = NO)
17 Correct 5 ms 256 KB OK (n = 3, answer = NO)
18 Correct 4 ms 256 KB OK (n = 100, answer = NO)
19 Correct 5 ms 384 KB OK (n = 100, answer = YES)
# 결과 실행 시간 메모리 Grader output
1 Incorrect 4 ms 256 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB OK (n = 1, answer = NO)
2 Correct 4 ms 384 KB OK (n = 1, answer = NO)
3 Correct 4 ms 256 KB OK (n = 1, answer = YES)
4 Correct 4 ms 256 KB OK (n = 2, answer = YES)
5 Correct 5 ms 256 KB OK (n = 2, answer = YES)
6 Correct 4 ms 256 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 384 KB OK (n = 3, answer = YES)
10 Correct 4 ms 256 KB OK (n = 3, answer = YES)
11 Correct 4 ms 256 KB OK (n = 3, answer = YES)
12 Correct 5 ms 384 KB OK (n = 3, answer = YES)
13 Correct 5 ms 256 KB OK (n = 3, answer = NO)
14 Correct 4 ms 256 KB OK (n = 3, answer = YES)
15 Correct 4 ms 256 KB OK (n = 3, answer = YES)
16 Correct 4 ms 256 KB OK (n = 3, answer = NO)
17 Correct 5 ms 256 KB OK (n = 3, answer = NO)
18 Correct 4 ms 256 KB OK (n = 100, answer = NO)
19 Correct 5 ms 384 KB OK (n = 100, answer = YES)
20 Incorrect 4 ms 256 KB Contestant can not find answer, jury can
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB OK (n = 1, answer = NO)
2 Correct 4 ms 384 KB OK (n = 1, answer = NO)
3 Correct 4 ms 256 KB OK (n = 1, answer = YES)
4 Correct 4 ms 256 KB OK (n = 2, answer = YES)
5 Correct 5 ms 256 KB OK (n = 2, answer = YES)
6 Correct 4 ms 256 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 384 KB OK (n = 3, answer = YES)
10 Correct 4 ms 256 KB OK (n = 3, answer = YES)
11 Correct 4 ms 256 KB OK (n = 3, answer = YES)
12 Correct 5 ms 384 KB OK (n = 3, answer = YES)
13 Correct 5 ms 256 KB OK (n = 3, answer = NO)
14 Correct 4 ms 256 KB OK (n = 3, answer = YES)
15 Correct 4 ms 256 KB OK (n = 3, answer = YES)
16 Correct 4 ms 256 KB OK (n = 3, answer = NO)
17 Correct 5 ms 256 KB OK (n = 3, answer = NO)
18 Correct 4 ms 256 KB OK (n = 100, answer = NO)
19 Correct 5 ms 384 KB OK (n = 100, answer = YES)
20 Incorrect 4 ms 256 KB Contestant can not find answer, jury can
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB OK (n = 1, answer = NO)
2 Correct 4 ms 384 KB OK (n = 1, answer = NO)
3 Correct 4 ms 256 KB OK (n = 1, answer = YES)
4 Correct 4 ms 256 KB OK (n = 2, answer = YES)
5 Correct 5 ms 256 KB OK (n = 2, answer = YES)
6 Correct 4 ms 256 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 384 KB OK (n = 3, answer = YES)
10 Correct 4 ms 256 KB OK (n = 3, answer = YES)
11 Correct 4 ms 256 KB OK (n = 3, answer = YES)
12 Correct 5 ms 384 KB OK (n = 3, answer = YES)
13 Correct 5 ms 256 KB OK (n = 3, answer = NO)
14 Correct 4 ms 256 KB OK (n = 3, answer = YES)
15 Correct 4 ms 256 KB OK (n = 3, answer = YES)
16 Correct 4 ms 256 KB OK (n = 3, answer = NO)
17 Correct 5 ms 256 KB OK (n = 3, answer = NO)
18 Correct 4 ms 256 KB OK (n = 100, answer = NO)
19 Correct 5 ms 384 KB OK (n = 100, answer = YES)
20 Incorrect 4 ms 256 KB Contestant can not find answer, jury can
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB OK (n = 1, answer = NO)
2 Correct 4 ms 384 KB OK (n = 1, answer = NO)
3 Correct 4 ms 256 KB OK (n = 1, answer = YES)
4 Correct 4 ms 256 KB OK (n = 2, answer = YES)
5 Correct 5 ms 256 KB OK (n = 2, answer = YES)
6 Correct 4 ms 256 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 384 KB OK (n = 3, answer = YES)
10 Correct 4 ms 256 KB OK (n = 3, answer = YES)
11 Correct 4 ms 256 KB OK (n = 3, answer = YES)
12 Correct 5 ms 384 KB OK (n = 3, answer = YES)
13 Correct 5 ms 256 KB OK (n = 3, answer = NO)
14 Correct 4 ms 256 KB OK (n = 3, answer = YES)
15 Correct 4 ms 256 KB OK (n = 3, answer = YES)
16 Correct 4 ms 256 KB OK (n = 3, answer = NO)
17 Correct 5 ms 256 KB OK (n = 3, answer = NO)
18 Correct 4 ms 256 KB OK (n = 100, answer = NO)
19 Correct 5 ms 384 KB OK (n = 100, answer = YES)
20 Incorrect 4 ms 256 KB Contestant can not find answer, jury can
21 Halted 0 ms 0 KB -