Submission #205370

# Submission time Handle Problem Language Result Execution time Memory
205370 2020-02-28T17:44:11 Z oko Detecting Molecules (IOI16_molecules) C++14
0 / 100
1000 ms 376 KB
#include <cstdio>
#include <vector>
#include <cassert>
#include<bits/stdc++.h>
#include "molecules.h"

using namespace std;
long long a,b,sum;
vector<pair<int,int> >v;
vector<int> find_subset(int l, int u, std::vector<int> w)
{
    for(int i=0;i<w.size();i++)v.push_back({w[i],i});
    sort(v.begin(),v.end());
    vector<int>ans;
    while(a<v.size())
    {
        if(sum<l&&b<v.size())
        {
            sum+=v[b].first;
            b++;
        }
        else if(u<sum)
        {
            sum-=v[a].first;
            a++;
        }
        if(l<=sum&&sum<=u)
        {
            for(int i=a;i<b;i++)ans.push_back(v[i].second);
            return ans;
        }
    }
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:12:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<w.size();i++)v.push_back({w[i],i});
                 ~^~~~~~~~~
molecules.cpp:15:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while(a<v.size())
           ~^~~~~~~~~
molecules.cpp:17:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         if(sum<l&&b<v.size())
                   ~^~~~~~~~~
molecules.cpp:33:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB OK (n = 12, answer = YES)
2 Correct 5 ms 376 KB OK (n = 12, answer = YES)
3 Execution timed out 1089 ms 256 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1091 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -