| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1170238 | mnbvcxz123 | Gift (IZhO18_nicegift) | C++20 | 2092 ms | 24732 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int N, K;
cin >> N >> K;
vector<ll> A(N);
for (int i = 0; i < N; i++) cin >> A[i];
vector<pair<ll, int>> sortedA;
for (int i = 0; i < N; i++) sortedA.emplace_back(A[i], i + 1);
sort(sortedA.begin(), sortedA.end());
vector<vector<int>> operations;
ll totalOps = 0;
while (!sortedA.empty()) {
vector<int> indices;
ll minVal = sortedA[0].first;
for (int i = 0; i < min(K, (int)sortedA.size()); i++) {
indices.push_back(sortedA[i].second);
sortedA[i].first -= minVal;
}
operations.push_back({minVal});
operations.back().insert(operations.back().end(), indices.begin(), indices.end());
totalOps += minVal;
sortedA.erase(remove_if(sortedA.begin(), sortedA.end(), [](pair<ll, int> p) { return p.first == 0; }), sortedA.end());
}
if ((ll)operations.size() * K > 3000000) {
cout << "-1\n";
return 0;
}
cout << operations.size() << "\n";
for (auto &op : operations) {
for (int x : op) cout << x << " ";
cout << "\n";
}
return 0;
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
