답안 #63288

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
63288 2018-08-01T08:43:26 Z KHUSRAV Detecting Molecules (IOI16_molecules) C++14
0 / 100
3 ms 576 KB
#include "molecules.h"
#include<bits/stdc++.h>
using namespace std ;
vector<int> find_subset(int l, int u, vector<int> w) {
    vector<pair<int , int> > v ;
    for(int i = 0 ; i < w.size() ; i++)
        v.push_back({w[i] , i});

    sort(v.begin() , v.end());
    vector<int> ans ;
    set<pair<int , int> > se ;
    int s = 0 ;
    int t = -1;
    for(int i = 0 ; i < v.size() && s < u; i++){
        s = s + v[i].first;
        t = i ;
    }
    s = 0 ;
    if(t == 0)
        return vector<int>();
    for(int i = 0 ; i <= t - 1 ; i ++){
        se.insert({v[i].first , v[i].second});
        s = s + v[i].first;
    }
    if(s >= l){
        for(auto it : se){
                ans.push_back(it.second);
        }
        return ans ;
    }
    for(int i = v.size() - 1 ; i >= t ; i -- ){
        s = s - se.begin()->first;
        s = s + v[i].first;
        se.erase(se.begin());
        se.insert({v[i].first , v[i].second});
        if(s >= l){
            for(auto it : se){
                ans.push_back(it.second);
            }
            return ans ;
        }
    }
    return vector<int>();
}

Compilation message

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