Submission #305536

# Submission time Handle Problem Language Result Execution time Memory
305536 2020-09-23T13:30:24 Z juggernaut Detecting Molecules (IOI16_molecules) C++14
0 / 100
1 ms 384 KB
#include<bits/stdc++.h>
using namespace std;
vector<int>find_subset(int a,int b,vector<int>w){
    vector<int>ans;
    vector<pair<int,int>>v;
    int i,l,r=0;
    long long int sum=0;
    for(;r<w.size();r++)v.push_back({w[r],r});
    sort(v.begin(),v.end());
    for(r=0;r<w.size();r++){
        sum+=v[r].first;
        while(sum>b)sum-=v[l++].first;
        if(sum>=a){
            for(;l<=r;l++)ans.push_back(v[l].second);
            return ans;
        }
    }
    return {};
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for(;r<w.size();r++)v.push_back({w[r],r});
      |          ~^~~~~~~~~
molecules.cpp:10:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(r=0;r<w.size();r++){
      |             ~^~~~~~~~~
molecules.cpp:6:9: warning: unused variable 'i' [-Wunused-variable]
    6 |     int i,l,r=0;
      |         ^
molecules.cpp:6:11: warning: 'l' may be used uninitialized in this function [-Wmaybe-uninitialized]
    6 |     int i,l,r=0;
      |           ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Runtime error 1 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Runtime error 1 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Runtime error 1 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Runtime error 1 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Runtime error 1 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Halted 0 ms 0 KB -