Submission #170021

# Submission time Handle Problem Language Result Execution time Memory
170021 2019-12-23T16:45:04 Z whttt Detecting Molecules (IOI16_molecules) C++14
0 / 100
3 ms 376 KB

#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long

using namespace std;

vector<ll> find_subset(int l, int u, vector<int> w){
    ll sum = 0;
    vector<ll> returnThis;
    sort(w.begin(), w.end());
    for(ll i = 0;i < w.size();i++){
        sum += w[i];
        if(sum <= u && sum >= l){
            for(ll j = 0;j <= i;j++){
                returnThis.push_back(w[i]);
            }
            return returnThis;
        } else if(sum > l){
            sum -= w[i];
            for(ll j = i;j < w.size();j++){
                sum += w[j]-w[j-i];
                if(sum <= u && sum >= l){
                    for(ll j = 0;j <= i;j++){
                        returnThis.push_back(w[i]);
                    }
                    return returnThis;
                }
                if(j == w.size()-1){
                    return {};
                }
            }
        }
    }
    return {};
}

Compilation message

molecules.cpp: In function 'std::vector<long long int> find_subset(int, int, std::vector<int>)':
molecules.cpp:14:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(ll i = 0;i < w.size();i++){
                  ~~^~~~~~~~~~
molecules.cpp:23:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(ll j = i;j < w.size();j++){
                          ~~^~~~~~~~~~
molecules.cpp:31:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if(j == w.size()-1){
                    ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 3 ms 376 KB Integer 2 violates the range [0, 1]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Integer 14 violates the range [0, 12]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 3 ms 376 KB Integer 2 violates the range [0, 1]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 3 ms 376 KB Integer 2 violates the range [0, 1]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 3 ms 376 KB Integer 2 violates the range [0, 1]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 3 ms 376 KB Integer 2 violates the range [0, 1]
4 Halted 0 ms 0 KB -