답안 #1082083

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1082083 2024-08-30T16:54:59 Z logangd Detecting Molecules (IOI16_molecules) C++14
0 / 100
0 ms 348 KB
#include "molecules.h"
#include<algorithm>
using namespace std;

vector<int> find_subset(int l, int u, vector<int> w) {
    vector<int>r;
    vector<pair<int,int>>v;
    for(int i=0;i<w.size();i++)v.push_back({w[i],i+1});
    sort(v.begin(),v.end());
    int i,j,s=0;
    for(i=0;i<v.size()&&s+v[i].first<=u;i++)s+=v[i].first;
    if(i==v.size()){
        if(l<=s&&s<=u){
            for(int k=0;k<i;k++)r.push_back(v[k].second);
        }
        return r;
    }
    for(i--,j=v.size()-1;0<=i&&s+v[j].first-v[i].first<=u;j--,i--)
        s+=v[j].first-v[i].first;
    if(l<=s&&s<=u){
        for(int k=0;k<=i;k++)r.push_back(v[k].second);
        for(int k=j+1;k<v.size();k++)r.push_back(v[k].second);
    }
    return r;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for(int i=0;i<w.size();i++)v.push_back({w[i],i+1});
      |                 ~^~~~~~~~~
molecules.cpp:11:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(i=0;i<v.size()&&s+v[i].first<=u;i++)s+=v[i].first;
      |             ~^~~~~~~~~
molecules.cpp:12:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     if(i==v.size()){
      |        ~^~~~~~~~~~
molecules.cpp:22:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for(int k=j+1;k<v.size();k++)r.push_back(v[k].second);
      |                       ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Integer 12 violates the range [0, 11]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -