제출 #811061

#제출 시각아이디문제언어결과실행 시간메모리
811061manhlinh1501Detecting Molecules (IOI16_molecules)C++17
0 / 100
0 ms212 KiB
/// @author : Hoang Manh Linh
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
 
#define pll pair<i64, i64>
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define lb(a, x) lower_bound(all(a), x) - a.begin()
 
int n;
int l, r;
 
vector<int> find_subset(int l,int r, vector<int> a) {
    int n = a.size();
    vector<i64> sum(n);
    vector<pll> res;
 
    for(int i = 0; i < n; i++)
        res.eb(a[i], i);
 	sort(all(res));
    sum.front() = res.front().first;
 
    for(int i = 1; i < n; i++)
        sum[i] = sum[i - 1] + res[i].first;
 
    vector<int> ans;
 
    for(int i = 0; i < n; i++) {
        int pos = lb(sum, sum[i] - res[i].first + l);
 
        if(pos >= n)
            continue;
 
        if(sum[pos] - sum[i] + res[i].first <= r) {
            for(int j = i; j <= pos; j++)
                ans.eb(res[j].second + 1);
 
            break;
        }
    }
 
    return ans;
}

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:19:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   19 |     for(int i = 0; i < n; i++)
      |     ^~~
molecules.cpp:21:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   21 |   sort(all(res));
      |   ^~~~
#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...