제출 #1020466

#제출 시각아이디문제언어결과실행 시간메모리
1020466vjudge1Detecting Molecules (IOI16_molecules)C++17
0 / 100
1 ms348 KiB
// #pragma once

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

std::vector<int> find_subset(int l, int u, std::vector<int> w){
	int mn = 1111, cnt = 0;
	for(int x: w){
		if(x < mn){
			mn = x;
			cnt = 0;
		}
		cnt += mn == x;
	}
	for(int i = 1; i <= w.size(); i++){
		int cal = max(0, (i - cal));
		if(mn * i + cal < l){
			cal = l - mn * i;
		}
		if(cal <= w.size() - cnt && mn * i + cal <= u){
			int x = i - cal, y = cal;
			vector<int> ans;
			for(int i = 0; i < w.size(); i++){
				if(w[i] == mn && x){
					x--; ans.push_back(i);
				} else if(w[i] == mn + 1 && y){
					y--; ans.push_back(i);
				}
			}
			return ans;
		}
	}
	return {};
}

컴파일 시 표준 에러 (stderr) 메시지

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:16:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |  for(int i = 1; i <= w.size(); i++){
      |                 ~~^~~~~~~~~~~
molecules.cpp:21:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |   if(cal <= w.size() - cnt && mn * i + cal <= u){
      |      ~~~~^~~~~~~~~~~~~~~~~
molecules.cpp:24:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |    for(int i = 0; i < w.size(); i++){
      |                   ~~^~~~~~~~~~
molecules.cpp:17:23: warning: 'cal' may be used uninitialized in this function [-Wmaybe-uninitialized]
   17 |   int cal = max(0, (i - cal));
      |                    ~~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...