Submission #319895

# Submission time Handle Problem Language Result Execution time Memory
319895 2020-11-06T16:57:57 Z tjdgus4384 Detecting Molecules (IOI16_molecules) C++14
0 / 100
1 ms 384 KB
#include<bits/stdc++.h>
#include "molecules.h"
using namespace std;

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

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:21: 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++){
      |                   ~~^~~~~~~~~~
molecules.cpp:12:21: 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 |     for(int i = 0;i < v.size();i++){
      |                   ~~^~~~~~~~~~
molecules.cpp:17:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |             for(int j = i+1;j < v.size();j++){
      |                             ~~^~~~~~~~~~
molecules.cpp:13:14: warning: 'sum1' may be used uninitialized in this function [-Wmaybe-uninitialized]
   13 |         sum1 += (long long)v[i].first; sum2 += (long long)v[v.size()-1-i].first;
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
molecules.cpp:13:45: warning: 'sum2' may be used uninitialized in this function [-Wmaybe-uninitialized]
   13 |         sum1 += (long long)v[i].first; sum2 += (long long)v[v.size()-1-i].first;
      |                                        ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB OK (n = 1, answer = NO)
2 Correct 1 ms 364 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 384 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB OK (n = 12, answer = YES)
2 Correct 1 ms 364 KB OK (n = 12, answer = YES)
3 Correct 1 ms 364 KB OK (n = 12, answer = NO)
4 Correct 1 ms 364 KB OK (n = 12, answer = NO)
5 Correct 1 ms 364 KB OK (n = 12, answer = YES)
6 Incorrect 1 ms 364 KB Contestant can not find answer, jury can
7 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB OK (n = 1, answer = NO)
2 Correct 1 ms 364 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 384 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB OK (n = 1, answer = NO)
2 Correct 1 ms 364 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 384 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB OK (n = 1, answer = NO)
2 Correct 1 ms 364 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 384 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB OK (n = 1, answer = NO)
2 Correct 1 ms 364 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 384 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -