# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
332246 | 2020-12-01T18:56:37 Z | vitkishloh228 | Gift (IZhO18_nicegift) | C++14 | 249 ms | 86652 KB |
#include<iostream> #include<vector> #include<algorithm> #include<deque> using namespace std; int main() { int n, k; cin >> n >> k; vector<int> a(n); for (int& i : a) cin >> i; deque<pair<int, int>> arr; for (int i = 0; i < n; ++i) { arr.push_back({ a[i],i }); } sort(arr.begin(), arr.end()); //reverse(arr.begin(), arr.end()); vector<vector<int>> ans; while (!arr.empty()) { if (k * ans.size() > 3 * 1e6) { cout << "-1"; return 0; } ans.push_back({}); if (arr.size() < k) continue; for (int i = (int)arr.size() - k; i < (int)arr.size(); ++i) { ans.back().push_back(arr[i].second + 1); arr[i].first--; } while (arr.size() && arr.front().first == 0) arr.pop_front(); } if (k * ans.size() > 3 * 1e6) { cout << "-1"; return 0; } cout << ans.size() << endl; for (auto elem : ans) { for (auto u : elem) cout << u << ' '; cout << "1\n"; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 192 ms | 82480 KB | Jury has the answer but participant has not |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 192 ms | 82480 KB | Jury has the answer but participant has not |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 192 ms | 82480 KB | Jury has the answer but participant has not |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 249 ms | 86652 KB | Jury has the answer but participant has not |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 192 ms | 82480 KB | Jury has the answer but participant has not |
2 | Halted | 0 ms | 0 KB | - |