답안 #161515

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
161515 2019-11-02T19:50:31 Z kostia244 Detecting Molecules (IOI16_molecules) C++14
0 / 100
167 ms 65540 KB
#include "molecules.h"
#include<bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
using ll = long long;
using vi = vector<int>;
vi find_subset(int l, int u, std::vector<int> w) {
	sort(all(w));
	vi ans;
	if(w[0]==w.back()) {
		for(int i = 0; i <= w.size(); i++) {
			if(i*w[0] >= l && u >= i*w[0]) {
				while(i--) {
					ans.pb(w[0]);
				}
				break;
			}
		}
	} else {
		for(int i = 0; i <= w.size(); i++) {
			if(i>0&&w[i-1]!=w[0]) break;
			for(int j = 0; j+i <= w.size(); j++) {
				if(j>0&&w[w.size()-j]!=w.back()) break;
				if(i*w[0] + j*w.back() >= l && u >= i*w[0] + j*w.back()) {
					while(i--) {
						ans.pb(w[0]);
					}
					while(j--) {
						ans.pb(w.back());
					}
					break;
				}
			}
		}
	}
    return ans;
}

Compilation message

molecules.cpp: In function 'vi find_subset(int, int, std::vector<int>)':
molecules.cpp:13:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i <= w.size(); i++) {
                  ~~^~~~~~~~~~~
molecules.cpp:22:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i <= w.size(); i++) {
                  ~~^~~~~~~~~~~
molecules.cpp:24:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for(int j = 0; j+i <= w.size(); j++) {
                   ~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 128 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 167 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 128 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 128 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 128 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 128 KB Integer 10 violates the range [0, 0]
4 Halted 0 ms 0 KB -