Submission #198353

# Submission time Handle Problem Language Result Execution time Memory
198353 2020-01-25T17:01:51 Z Ruxandra985 Detecting Molecules (IOI16_molecules) C++14
0 / 100
2 ms 256 KB
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;

vector <int> sol;
pair <int,int> x[200010];
vector <int> find_subset (int l , int u , vector <int> v){
    int i , sum;
    for (i=0;i<v.size();i++){
        x[i] = make_pair(v[i] , i);
    }
    sort (x , x + v.size());

    sum = 0;
    for (i = v.size() - 1 ; i>=0 ;i--){
        if (sum + x[i].first <= u && (sum + x[i].first >= l || sum + x[i].first + x[0].first <= u)){
            sum += x[i].first;
            sol.push_back(x[i].second);
        }
        if (sum >= l){
            return sol;
        }
    }
    sol.clear();


    sum = 0;
    for (i = 0 ; i<v.size() ;i++){
        if (sum + x[i].first <= u && (sum + x[i].first >= l || sum + x[i].first + x[i+1].first <= u)){
            sum += x[i].first;
            sol.push_back(x[i].second);
        }
        if (sum >= l){
            return sol;
        }
    }


    return sol; /// nu se poate;

}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:9:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (i=0;i<v.size();i++){
              ~^~~~~~~~~
molecules.cpp:28:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (i = 0 ; i<v.size() ;i++){
                  ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB OK (n = 12, answer = YES)
2 Correct 2 ms 256 KB OK (n = 12, answer = YES)
3 Incorrect 2 ms 256 KB sum of weights should be in [307..317] but it is 301
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -