Submission #403315

#TimeUsernameProblemLanguageResultExecution timeMemory
403315MDarioDetecting Molecules (IOI16_molecules)C++11
100 / 100
55 ms4032 KiB
#include "molecules.h"
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
vector<int> find_subset(int l, int u, vector<int> z){
    vector<int> v;
    vector<pair<int, int>> w;
    unsigned int c=0, s=0, n=z.size();
    for(int i=0; i<n; i++){
        w.push_back({z[i], i});
    }
    sort(w.begin(), w.end());
    reverse(w.begin(), w.end());
    for(int i=0; i<n; i++){
        while(s<l&&c<n){
            s+=w[c].F;
            c++;
        }
        if(l<=s&&s<=u){
            for(int t=i; t<c; t++)v.push_back(w[t].S);
            break;
        }
        s-=w[i].F;
    }
    return v;
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:10:19: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
   10 |     for(int i=0; i<n; i++){
      |                  ~^~
molecules.cpp:15:19: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
   15 |     for(int i=0; i<n; i++){
      |                  ~^~
molecules.cpp:16:16: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   16 |         while(s<l&&c<n){
      |               ~^~
molecules.cpp:20:13: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
   20 |         if(l<=s&&s<=u){
      |            ~^~~
molecules.cpp:20:19: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
   20 |         if(l<=s&&s<=u){
      |                  ~^~~
molecules.cpp:21:27: warning: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare]
   21 |             for(int t=i; t<c; t++)v.push_back(w[t].S);
      |                          ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...