답안 #122275

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
122275 2019-06-28T03:44:12 Z turbat Detecting Molecules (IOI16_molecules) C++14
0 / 100
2 ms 384 KB
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;


vector<int> find_subset(int l, int u, vector<int> w) {
    vector <int> ans;
    vector <pair <int, int> > v;
    for (int i = 0;i < w.size();i++)
    	v.push_back({w[i], i});
    sort(v.begin(), v.end());
    int s = 0;
    for (int i = 1;i < v.size();i++){
    	if (s + v[i].first <= u){
 			s += v[i].first;
    		ans.push_back(v[i].second);
    	}
    	else {
    		if (s < l){
    			ans.push_back(v.back().second);
    			ans.erase(ans.begin() + 0);
    			if (s + v.back().first - v[0].first < l || s + v.back().first - v[0].first > u)
    				ans.clear();
    		}
    		break;
    	}
    }
    // cout << l << ' ' << u << endl;
    // for (int x : ans)
    // 	cout << x<< ' ';
    // cout << endl;
    sort(ans.begin(), ans.end());
    return ans;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:9:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0;i < w.size();i++)
                    ~~^~~~~~~~~~
molecules.cpp:13:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 1;i < v.size();i++){
                    ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB OK (n = 1, answer = NO)
2 Correct 2 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 384 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 256 KB OK (n = 12, answer = YES)
2 Correct 2 ms 256 KB OK (n = 12, answer = YES)
3 Correct 2 ms 384 KB OK (n = 12, answer = NO)
4 Correct 2 ms 356 KB OK (n = 12, answer = NO)
5 Incorrect 2 ms 384 KB Contestant can not find answer, jury can
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB OK (n = 1, answer = NO)
2 Correct 2 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 384 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB OK (n = 1, answer = NO)
2 Correct 2 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 384 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB OK (n = 1, answer = NO)
2 Correct 2 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 384 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 384 KB OK (n = 1, answer = NO)
2 Correct 2 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 384 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -