답안 #139426

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
139426 2019-07-31T16:32:48 Z quotitquot Detecting Molecules (IOI16_molecules) C++14
0 / 100
2 ms 376 KB
#include "molecules.h"
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr first
#define se second
using namespace std;

std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    vector<int>res;
    ll now = 0;
    vector<pair<ll,ll>>V;
    for( int i = 0; i < w.size(); i ++ )
        V.pb( { w[i], i } );
    sort( V.begin(), V.end() );
    if( V[0].fr <= u )
    {
        for( int i = 0; i < V.size(); i ++ )
        {
            now += V[i].fr;
            res.pb( V[i].se );
            while( now > u )
            {
                now -= V[res[0]].fr;
                res.erase( res.begin() );
            }
            if( now >= l )
            {
                for( int j = 0; j < res.size(); j ++ )
                    res[i] ++;
                sort( res.begin(), res.end() );
                return res;
            }
        }
    }
    res.pb( 0 );
    return res;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:13:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for( int i = 0; i < w.size(); i ++ )
                     ~~^~~~~~~~~~
molecules.cpp:18:27: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for( int i = 0; i < V.size(); i ++ )
                         ~~^~~~~~~~~~
molecules.cpp:29:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 for( int j = 0; j < res.size(); j ++ )
                                 ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Integer 2 violates the range [0, 1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 12, answer = YES)
2 Correct 2 ms 376 KB OK (n = 12, answer = YES)
3 Incorrect 2 ms 256 KB sum of weights should be in [307..317] but it is 356
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Integer 2 violates the range [0, 1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Integer 2 violates the range [0, 1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Integer 2 violates the range [0, 1]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Integer 2 violates the range [0, 1]
2 Halted 0 ms 0 KB -