답안 #72571

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72571 2018-08-26T09:43:12 Z aleksam Detecting Molecules (IOI16_molecules) C++14
9 / 100
6 ms 780 KB
#pragma once

#include <bits/stdc++.h>
#define MAX_N 500000

using namespace std;

long long L[MAX_N], D[MAX_N];
int N;
set<long long> S;
vector<int> find_subset(int l, int u, vector<int> w) {
	N=w.size();
	sort(w.begin(), w.end());
	L[0]=w[0];
	for(int i=0; i<N; ++i){
		if(i)
			L[i]=L[i-1]+w[i];
		if(L[i]>=l && L[i]<=u){
			vector<int> ret;
			for(int j=0;  j<i+1; ++j){
				ret.push_back(j);
			}
			return ret;
		}
	}
	D[N-1]=w[N-1];
	for(int i=N-1; i>=0; --i){
		if(N-1-i)
			D[i]=D[i+1]+w[i];
		if(D[i]>=l && D[i]<=u){
			vector<int> ret;
			for(int j=N-1;  j>=i; --j){
				ret.push_back(j);
			}
			return ret;
		}
	}
	for(int i=N-2; i>=0; --i){
		S.insert(D[i+1]);
		auto x=S.lower_bound((long long)l-L[i]);
		if(x==S.end())continue;
		long long val=*x;
		if(val<=(long long)u-L[i]){
			//To je to, nasao sam resenje
			vector<int> ret;
			int ind=-1;
			for(int j=i+1; j<N; ++j)
				if(D[j]==val)
					ind=j;
			for(int j=0; j<=i; ++j)
				ret.push_back(j);
			for(int j=ind; j<N; ++j)
				ret.push_back(j);
			int d=ret.size();
			int sum=0;
			for(int j=0; j<d; ++j)
				sum+=ret[j];
			//assert(sum==L[i]+D[ind]);
			//assert(sum<=u && sum>=l);
			return ret;
		}
	}
	vector<int> ret;
	return ret;
}

Compilation message

molecules.cpp:1:9: warning: #pragma once in main file
 #pragma once
         ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB OK (n = 1, answer = NO)
2 Correct 6 ms 484 KB OK (n = 1, answer = NO)
3 Correct 2 ms 484 KB OK (n = 1, answer = YES)
4 Correct 2 ms 620 KB OK (n = 2, answer = YES)
5 Correct 2 ms 660 KB OK (n = 2, answer = YES)
6 Correct 2 ms 660 KB OK (n = 3, answer = YES)
7 Correct 2 ms 660 KB OK (n = 3, answer = YES)
8 Correct 2 ms 732 KB OK (n = 3, answer = YES)
9 Correct 2 ms 736 KB OK (n = 3, answer = YES)
10 Correct 2 ms 740 KB OK (n = 3, answer = YES)
11 Correct 3 ms 744 KB OK (n = 3, answer = YES)
12 Correct 3 ms 748 KB OK (n = 3, answer = YES)
13 Correct 2 ms 752 KB OK (n = 3, answer = NO)
14 Correct 2 ms 760 KB OK (n = 3, answer = YES)
15 Correct 2 ms 760 KB OK (n = 3, answer = YES)
16 Correct 2 ms 764 KB OK (n = 3, answer = NO)
17 Correct 3 ms 768 KB OK (n = 3, answer = NO)
18 Correct 3 ms 772 KB OK (n = 100, answer = NO)
19 Correct 3 ms 776 KB OK (n = 100, answer = YES)
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 780 KB OK (n = 12, answer = YES)
2 Correct 2 ms 780 KB OK (n = 12, answer = YES)
3 Correct 2 ms 780 KB OK (n = 12, answer = NO)
4 Correct 2 ms 780 KB OK (n = 12, answer = NO)
5 Correct 2 ms 780 KB OK (n = 12, answer = YES)
6 Correct 2 ms 780 KB OK (n = 12, answer = YES)
7 Correct 2 ms 780 KB OK (n = 12, answer = YES)
8 Correct 3 ms 780 KB OK (n = 12, answer = YES)
9 Correct 2 ms 780 KB OK (n = 6, answer = YES)
10 Correct 2 ms 780 KB OK (n = 12, answer = YES)
11 Correct 3 ms 780 KB OK (n = 100, answer = NO)
12 Incorrect 3 ms 780 KB sum of weights should be in [50..51] but it is 73
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB OK (n = 1, answer = NO)
2 Correct 6 ms 484 KB OK (n = 1, answer = NO)
3 Correct 2 ms 484 KB OK (n = 1, answer = YES)
4 Correct 2 ms 620 KB OK (n = 2, answer = YES)
5 Correct 2 ms 660 KB OK (n = 2, answer = YES)
6 Correct 2 ms 660 KB OK (n = 3, answer = YES)
7 Correct 2 ms 660 KB OK (n = 3, answer = YES)
8 Correct 2 ms 732 KB OK (n = 3, answer = YES)
9 Correct 2 ms 736 KB OK (n = 3, answer = YES)
10 Correct 2 ms 740 KB OK (n = 3, answer = YES)
11 Correct 3 ms 744 KB OK (n = 3, answer = YES)
12 Correct 3 ms 748 KB OK (n = 3, answer = YES)
13 Correct 2 ms 752 KB OK (n = 3, answer = NO)
14 Correct 2 ms 760 KB OK (n = 3, answer = YES)
15 Correct 2 ms 760 KB OK (n = 3, answer = YES)
16 Correct 2 ms 764 KB OK (n = 3, answer = NO)
17 Correct 3 ms 768 KB OK (n = 3, answer = NO)
18 Correct 3 ms 772 KB OK (n = 100, answer = NO)
19 Correct 3 ms 776 KB OK (n = 100, answer = YES)
20 Correct 2 ms 780 KB OK (n = 12, answer = YES)
21 Correct 2 ms 780 KB OK (n = 12, answer = YES)
22 Correct 2 ms 780 KB OK (n = 12, answer = NO)
23 Correct 2 ms 780 KB OK (n = 12, answer = NO)
24 Correct 2 ms 780 KB OK (n = 12, answer = YES)
25 Correct 2 ms 780 KB OK (n = 12, answer = YES)
26 Correct 2 ms 780 KB OK (n = 12, answer = YES)
27 Correct 3 ms 780 KB OK (n = 12, answer = YES)
28 Correct 2 ms 780 KB OK (n = 6, answer = YES)
29 Correct 2 ms 780 KB OK (n = 12, answer = YES)
30 Correct 3 ms 780 KB OK (n = 100, answer = NO)
31 Incorrect 3 ms 780 KB sum of weights should be in [50..51] but it is 73
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB OK (n = 1, answer = NO)
2 Correct 6 ms 484 KB OK (n = 1, answer = NO)
3 Correct 2 ms 484 KB OK (n = 1, answer = YES)
4 Correct 2 ms 620 KB OK (n = 2, answer = YES)
5 Correct 2 ms 660 KB OK (n = 2, answer = YES)
6 Correct 2 ms 660 KB OK (n = 3, answer = YES)
7 Correct 2 ms 660 KB OK (n = 3, answer = YES)
8 Correct 2 ms 732 KB OK (n = 3, answer = YES)
9 Correct 2 ms 736 KB OK (n = 3, answer = YES)
10 Correct 2 ms 740 KB OK (n = 3, answer = YES)
11 Correct 3 ms 744 KB OK (n = 3, answer = YES)
12 Correct 3 ms 748 KB OK (n = 3, answer = YES)
13 Correct 2 ms 752 KB OK (n = 3, answer = NO)
14 Correct 2 ms 760 KB OK (n = 3, answer = YES)
15 Correct 2 ms 760 KB OK (n = 3, answer = YES)
16 Correct 2 ms 764 KB OK (n = 3, answer = NO)
17 Correct 3 ms 768 KB OK (n = 3, answer = NO)
18 Correct 3 ms 772 KB OK (n = 100, answer = NO)
19 Correct 3 ms 776 KB OK (n = 100, answer = YES)
20 Correct 2 ms 780 KB OK (n = 12, answer = YES)
21 Correct 2 ms 780 KB OK (n = 12, answer = YES)
22 Correct 2 ms 780 KB OK (n = 12, answer = NO)
23 Correct 2 ms 780 KB OK (n = 12, answer = NO)
24 Correct 2 ms 780 KB OK (n = 12, answer = YES)
25 Correct 2 ms 780 KB OK (n = 12, answer = YES)
26 Correct 2 ms 780 KB OK (n = 12, answer = YES)
27 Correct 3 ms 780 KB OK (n = 12, answer = YES)
28 Correct 2 ms 780 KB OK (n = 6, answer = YES)
29 Correct 2 ms 780 KB OK (n = 12, answer = YES)
30 Correct 3 ms 780 KB OK (n = 100, answer = NO)
31 Incorrect 3 ms 780 KB sum of weights should be in [50..51] but it is 73
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB OK (n = 1, answer = NO)
2 Correct 6 ms 484 KB OK (n = 1, answer = NO)
3 Correct 2 ms 484 KB OK (n = 1, answer = YES)
4 Correct 2 ms 620 KB OK (n = 2, answer = YES)
5 Correct 2 ms 660 KB OK (n = 2, answer = YES)
6 Correct 2 ms 660 KB OK (n = 3, answer = YES)
7 Correct 2 ms 660 KB OK (n = 3, answer = YES)
8 Correct 2 ms 732 KB OK (n = 3, answer = YES)
9 Correct 2 ms 736 KB OK (n = 3, answer = YES)
10 Correct 2 ms 740 KB OK (n = 3, answer = YES)
11 Correct 3 ms 744 KB OK (n = 3, answer = YES)
12 Correct 3 ms 748 KB OK (n = 3, answer = YES)
13 Correct 2 ms 752 KB OK (n = 3, answer = NO)
14 Correct 2 ms 760 KB OK (n = 3, answer = YES)
15 Correct 2 ms 760 KB OK (n = 3, answer = YES)
16 Correct 2 ms 764 KB OK (n = 3, answer = NO)
17 Correct 3 ms 768 KB OK (n = 3, answer = NO)
18 Correct 3 ms 772 KB OK (n = 100, answer = NO)
19 Correct 3 ms 776 KB OK (n = 100, answer = YES)
20 Correct 2 ms 780 KB OK (n = 12, answer = YES)
21 Correct 2 ms 780 KB OK (n = 12, answer = YES)
22 Correct 2 ms 780 KB OK (n = 12, answer = NO)
23 Correct 2 ms 780 KB OK (n = 12, answer = NO)
24 Correct 2 ms 780 KB OK (n = 12, answer = YES)
25 Correct 2 ms 780 KB OK (n = 12, answer = YES)
26 Correct 2 ms 780 KB OK (n = 12, answer = YES)
27 Correct 3 ms 780 KB OK (n = 12, answer = YES)
28 Correct 2 ms 780 KB OK (n = 6, answer = YES)
29 Correct 2 ms 780 KB OK (n = 12, answer = YES)
30 Correct 3 ms 780 KB OK (n = 100, answer = NO)
31 Incorrect 3 ms 780 KB sum of weights should be in [50..51] but it is 73
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 248 KB OK (n = 1, answer = NO)
2 Correct 6 ms 484 KB OK (n = 1, answer = NO)
3 Correct 2 ms 484 KB OK (n = 1, answer = YES)
4 Correct 2 ms 620 KB OK (n = 2, answer = YES)
5 Correct 2 ms 660 KB OK (n = 2, answer = YES)
6 Correct 2 ms 660 KB OK (n = 3, answer = YES)
7 Correct 2 ms 660 KB OK (n = 3, answer = YES)
8 Correct 2 ms 732 KB OK (n = 3, answer = YES)
9 Correct 2 ms 736 KB OK (n = 3, answer = YES)
10 Correct 2 ms 740 KB OK (n = 3, answer = YES)
11 Correct 3 ms 744 KB OK (n = 3, answer = YES)
12 Correct 3 ms 748 KB OK (n = 3, answer = YES)
13 Correct 2 ms 752 KB OK (n = 3, answer = NO)
14 Correct 2 ms 760 KB OK (n = 3, answer = YES)
15 Correct 2 ms 760 KB OK (n = 3, answer = YES)
16 Correct 2 ms 764 KB OK (n = 3, answer = NO)
17 Correct 3 ms 768 KB OK (n = 3, answer = NO)
18 Correct 3 ms 772 KB OK (n = 100, answer = NO)
19 Correct 3 ms 776 KB OK (n = 100, answer = YES)
20 Correct 2 ms 780 KB OK (n = 12, answer = YES)
21 Correct 2 ms 780 KB OK (n = 12, answer = YES)
22 Correct 2 ms 780 KB OK (n = 12, answer = NO)
23 Correct 2 ms 780 KB OK (n = 12, answer = NO)
24 Correct 2 ms 780 KB OK (n = 12, answer = YES)
25 Correct 2 ms 780 KB OK (n = 12, answer = YES)
26 Correct 2 ms 780 KB OK (n = 12, answer = YES)
27 Correct 3 ms 780 KB OK (n = 12, answer = YES)
28 Correct 2 ms 780 KB OK (n = 6, answer = YES)
29 Correct 2 ms 780 KB OK (n = 12, answer = YES)
30 Correct 3 ms 780 KB OK (n = 100, answer = NO)
31 Incorrect 3 ms 780 KB sum of weights should be in [50..51] but it is 73
32 Halted 0 ms 0 KB -