제출 #997083

#제출 시각아이디문제언어결과실행 시간메모리
997083codefoxDetecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define pii pair<int, int> int[] find_subset(int l, int u, int[] w) { vector<pii> nums; for (int i = 0; i < n; i++) nums.push_back({w[i], i}); sort(nums.begin(), nums.end()); int left=0, right=0; long long sum = 0; while (sum <= l) { sum += nums[right].first; right++; } right--; sum -= nums[right].first; while (sum <= u) { sum += nums[right].first; right++; sum -= nums[left].first; left++; } right--; sum -= nums[right].first; left--; sum -= nums[left].first; if (sum >= l) {ac int ans[right-left]; for (int i = left; i < right; i++) { ans[i-left] = nums[i].second; } return ans; } else { int ans[0]; return ans; } }

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

molecules.cpp:7:4: error: structured binding declaration cannot have type 'int'
    7 | int[] find_subset(int l, int u, int[] w)
      |    ^~
molecules.cpp:7:4: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
molecules.cpp:7:4: error: empty structured binding declaration
molecules.cpp:7:7: error: expected initializer before 'find_subset'
    7 | int[] find_subset(int l, int u, int[] w)
      |       ^~~~~~~~~~~