# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
386701 |
2021-04-07T08:27:37 Z |
vanic |
Gift (IZhO18_nicegift) |
C++14 |
|
2000 ms |
142316 KB |
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <array>
using namespace std;
typedef long long ll;
const int maxn=1e6+5;
ll a[maxn];
ll sum;
array < ll, 3 > v[maxn*4];
set < int > cur;
void scan(ll &a){
a=0;
char c=getchar();
while(c>='0' && c<='9'){
a*=10;
a+=c-'0';
c=getchar();
}
}
int main(){
ll n, k;
scan(n);
scan(k);
for(int i=0; i<n; i++){
scan(a[i]);
sum+=a[i];
}
if(sum%k){
printf("-1\n");
return 0;
}
sum/=k;
for(int i=0; i<n; i++){
if(a[i]>sum){
printf("-1\n");
return 0;
}
}
int pos=0;
int iduc;
int br=0;
for(int i=0; i<n; i++){
iduc=pos+a[i];
if(iduc>sum){
v[br]={pos, i+1, 1};
br++;
v[br]={sum, i+1, 0};
br++;
iduc-=sum;
pos=0;
}
v[br]={pos, i+1, 1};
br++;
v[br]={iduc, i+1, 0};
br++;
if(iduc==sum){
iduc=0;
}
pos=iduc;
}
sort(v, v+br);
int sol=0;
for(int i=0; i<br-1; i++){
if(v[i][0]!=v[i+1][0]){
sol++;
}
}
printf("%d\n", sol);
for(int i=0; i<br; i++){
if(v[i][2]){
cur.insert(v[i][1]);
}
else{
cur.erase(v[i][1]);
}
if(i==br-1 || v[i][0]==v[i+1][0]){
continue;
}
printf("%lld ", v[i+1][0]-v[i][0]);
for(set < int >::iterator it=cur.begin(); it!=cur.end(); it++){
printf("%d ", *it);
}
printf("\n");
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Taken too much stones from the heap |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Taken too much stones from the heap |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Taken too much stones from the heap |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2080 ms |
142316 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
364 KB |
Taken too much stones from the heap |
2 |
Halted |
0 ms |
0 KB |
- |