Submission #963185

# Submission time Handle Problem Language Result Execution time Memory
963185 2024-04-14T16:41:06 Z maxFedorchuk Detecting Molecules (IOI16_molecules) C++17
0 / 100
1 ms 352 KB
#include <bits/stdc++.h>
using namespace std;

//#include "molecules.h"

vector<int> find_subset(const int l,const int u,const vector<int> w) 
{
    vector < pair < int ,int > > mas;
    vector < int > ans;

    for(int i=0;i<w.size();i++)
    {
        mas.push_back({w[i],i+1});
    }

    sort(mas.begin(),mas.end());

    for(int sum=0,ru=0,lu=0;ru<w.size();ru++)
    {
        sum+=mas[ru].first;

        while(sum>u)
        {
            sum-=mas[lu].first;
            lu++;
        }

        if(sum>=l)
        {
            for(int j=lu;j<=ru;j++)
            {
                ans.push_back(mas[j].second);
            }

            break;
        }
    }

    return ans;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:12:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for(int i=0;i<w.size();i++)
      |                 ~^~~~~~~~~
molecules.cpp:19:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(int sum=0,ru=0,lu=0;ru<w.size();ru++)
      |                             ~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (n = 1, answer = NO)
2 Correct 1 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 352 KB OK (n = 12, answer = YES)
2 Correct 0 ms 348 KB OK (n = 12, answer = YES)
3 Correct 0 ms 348 KB OK (n = 12, answer = NO)
4 Correct 0 ms 348 KB OK (n = 12, answer = NO)
5 Incorrect 0 ms 348 KB sum of weights should be in [290..300] but it is 301
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (n = 1, answer = NO)
2 Correct 1 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (n = 1, answer = NO)
2 Correct 1 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (n = 1, answer = NO)
2 Correct 1 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB OK (n = 1, answer = NO)
2 Correct 1 ms 348 KB OK (n = 1, answer = NO)
3 Incorrect 0 ms 348 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -