제출 #1283412

#제출 시각아이디문제언어결과실행 시간메모리
1283412LeynaDetecting Molecules (IOI16_molecules)C++20
0 / 100
1 ms348 KiB
#include "molecules.h" #include <bits/stdc++.h> #define all(x) x.begin(), x.end() using namespace std; using ll = long long; vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); vector<pair<ll, ll>> weights; for (int i=0; i<n; i++) weights.push_back({w[i], i}); int left = 0, right = 1; sort(all(weights)); ll sum = weights[0].first; bool possible = false; while (left < right && (right < n || (right == n && sum >= u))){ if (sum < l){ sum += weights[right++].first; } else if (sum > u){ sum -= weights[left++].first; } else{ possible = true; break; } } //cerr << left << " " << right << endl; //cerr << "possible: " << possible << endl; vector<int> result; if (possible){ for (int i=left; i<right; i++){ result.push_back(weights[i].second); } } return result; }

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

molecules.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
#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...