제출 #568382

#제출 시각아이디문제언어결과실행 시간메모리
568382Trisanu_DasDetecting Molecules (IOI16_molecules)C++17
46 / 100
4 ms688 KiB
#include "molecules.h" #include<bits/stdc++.h> #define f first #define s second using namespace std; vector<int> find_subset(int l, int r, vector<int> w) { vector<pair<int, int>> w_sort; for(int i = 0; i < w.size(); i++) { w_sort.push_back({w[i], i}); } sort(w_sort.begin(), w_sort.end()); int sum = 0; vector<int> ans; for(int i = 0; i < w_sort.size(); i++) { sum += w_sort[i].f; ans.push_back(w_sort[i].s); if(sum >= l && sum <= r)return ans; } ans.clear(); if(sum < l) return ans; if(w_sort[0].f > r) return ans; int last = 0; sum = 0; for(int i = 0; i < w_sort.size(); i++) { if(sum + w_sort[i].f > l) break; sum += w_sort[i].f; last = i; } int len = last + 1; for(int i = last + 1; i < w_sort.size(); i++) { sum -= w_sort[i - len].f; sum += w_sort[i].f; if(sum >= l) { for(int j = i - len + 1; j <= i; j++) ans.push_back(w_sort[j].s); return ans; } } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:9:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int i = 0; i < w.size(); i++) {
      |                    ~~^~~~~~~~~~
molecules.cpp:15:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |  for(int i = 0; i < w_sort.size(); i++) {
      |                 ~~^~~~~~~~~~~~~~~
molecules.cpp:25:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for(int i = 0; i < w_sort.size(); i++) {
      |                 ~~^~~~~~~~~~~~~~~
molecules.cpp:31:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for(int i = last + 1; i < w_sort.size(); i++) {
      |                        ~~^~~~~~~~~~~~~~~
#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...