# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
57406 |
2018-07-14T22:23:21 Z |
hugo_pm |
Gift (IZhO18_nicegift) |
C++14 |
|
774 ms |
73532 KB |
#include <bits/stdc++.h>
#define int long long
#pragma GCC diagnostic ignored "-Wunused-result"
#define len(v) (int)(v.size())
using namespace std;
typedef pair<int, int> pii;
const int maxVerrous = 1000*1000;
int nbVerrous, tailleOperation;
int reqUnlock[maxVerrous];
int cur[maxVerrous];
struct Machin
{
int req, ind;
bool operator< (Machin oth) const
{
int c1 = reqUnlock[ind] - cur[ind];
int c2 = reqUnlock[oth.ind] - cur[oth.ind];
if (c1 != c2) return c1 < c2;
else return ind < oth.ind;
}
};
vector<Machin> tab;
set<Machin> wcur;
signed main()
{
scanf("%lld%lld", &nbVerrous, &tailleOperation);
tab.resize(nbVerrous);
for (int indVerrou = 0; indVerrou < nbVerrous; ++indVerrou) {
scanf("%lld", &reqUnlock[indVerrou]);
tab[indVerrou] = {reqUnlock[indVerrou], indVerrou};
}
sort(tab.begin(), tab.end());
vector<vector<int>> operations;
operations.reserve(100*1000);
vector<int> curOp(tailleOperation + 1);
int indOp = 0;
while ((! tab.empty()) || (! wcur.empty())) {
++indOp;
if (indOp * tailleOperation > 3*1000*1000 || len(tab) + len(wcur) < tailleOperation) {
printf("-1\n");
return 0;
}
while (len(wcur) < tailleOperation) {
wcur.insert(tab.back());
tab.pop_back();
}
auto it = wcur.begin();
int rem = reqUnlock[it->ind] - cur[it->ind];
curOp[0] = rem;
for (int ind = 1; ind <= tailleOperation; ++ind) {
curOp[ind] = it->ind + 1;
cur[it->ind] += rem;
++it;
}
operations.push_back(curOp);
while ((! wcur.empty()) && (reqUnlock[wcur.begin()->ind] == cur[wcur.begin()->ind])) {
wcur.erase(wcur.begin());
}
}
printf("%lld\n", (int)(operations.size()));
for (auto op : operations) {
for (int choisi : op) {
printf("%lld ", choisi);
}
printf("\n");
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
n=4 |
2 |
Correct |
2 ms |
376 KB |
n=3 |
3 |
Correct |
2 ms |
540 KB |
n=3 |
4 |
Correct |
3 ms |
540 KB |
n=4 |
5 |
Correct |
3 ms |
540 KB |
n=4 |
6 |
Correct |
2 ms |
556 KB |
n=2 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
n=4 |
2 |
Correct |
2 ms |
376 KB |
n=3 |
3 |
Correct |
2 ms |
540 KB |
n=3 |
4 |
Correct |
3 ms |
540 KB |
n=4 |
5 |
Correct |
3 ms |
540 KB |
n=4 |
6 |
Correct |
2 ms |
556 KB |
n=2 |
7 |
Correct |
2 ms |
556 KB |
n=5 |
8 |
Correct |
3 ms |
556 KB |
n=8 |
9 |
Incorrect |
3 ms |
620 KB |
Jury has the answer but participant has not |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
n=4 |
2 |
Correct |
2 ms |
376 KB |
n=3 |
3 |
Correct |
2 ms |
540 KB |
n=3 |
4 |
Correct |
3 ms |
540 KB |
n=4 |
5 |
Correct |
3 ms |
540 KB |
n=4 |
6 |
Correct |
2 ms |
556 KB |
n=2 |
7 |
Correct |
2 ms |
556 KB |
n=5 |
8 |
Correct |
3 ms |
556 KB |
n=8 |
9 |
Incorrect |
3 ms |
620 KB |
Jury has the answer but participant has not |
10 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
774 ms |
73532 KB |
n=1000000 |
2 |
Correct |
404 ms |
73532 KB |
n=666666 |
3 |
Correct |
222 ms |
73532 KB |
n=400000 |
4 |
Incorrect |
112 ms |
73532 KB |
Jury has the answer but participant has not |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
376 KB |
n=4 |
2 |
Correct |
2 ms |
376 KB |
n=3 |
3 |
Correct |
2 ms |
540 KB |
n=3 |
4 |
Correct |
3 ms |
540 KB |
n=4 |
5 |
Correct |
3 ms |
540 KB |
n=4 |
6 |
Correct |
2 ms |
556 KB |
n=2 |
7 |
Correct |
2 ms |
556 KB |
n=5 |
8 |
Correct |
3 ms |
556 KB |
n=8 |
9 |
Incorrect |
3 ms |
620 KB |
Jury has the answer but participant has not |
10 |
Halted |
0 ms |
0 KB |
- |