답안 #125810

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
125810 2019-07-06T11:51:50 Z Sorting Detecting Molecules (IOI16_molecules) C++14
0 / 100
2 ms 504 KB
#include <bits/stdc++.h>

using namespace std;

const int N = 2e5 + 7;

long long prefix[N], suffix[N];

long long find_sum(int l, int r){
	if(l == 0){
		return prefix[r];
	}

	return prefix[r] - prefix[l - 1];
}

vector<int> find_subset(int l, int r, vector<int> w){
	vector<int> ans;
	int n = (int)w.size();
	vector<pair<long long, int> > a;

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

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

	prefix[0] = a[0].second;
	for(int i = 1; i < n; i++){
		prefix[i] = prefix[i - 1] + (long long)a[i].second;
	}

	for(int i = 1; i <= n; i++){
		if(find_sum(0, i - 1) > r || find_sum(n - i, n - 1) < l){
			continue;
		}

		for(int j = 0; j <= n - i; j++){
			long long sum = find_sum(j, j + i - 1);

			if(l <= sum && sum <= r){
				for(int k = 0; k < i; k++){
					ans.push_back(j + k);
				}

				return ans;
			}
		}

		while(true);
	}

	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 504 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 256 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 504 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 504 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 504 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 504 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 376 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -