# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
644 |
2013-02-28T18:33:22 Z |
jwvg0425 |
파일 삭제 (GA3_delete) |
C++ |
|
0 ms |
944 KB |
#include <algorithm>
struct F{int a,b;};
F D[4000];
void addFile(int i, int* B)
{
D[i].a++;
if(i==0)
return;
addFile(B[i],B);
}
void UpDelete(int i,int r,int M,int* B)
{
int k;
for(k=0;D[k].b!=i;k++);
D[k].a-=r;
if(B[i]==-1)
return;
UpDelete(B[D[k].b],r,M,B);
}
void deleteDir(int i,int M,int* B)
{
int j,k,t=0;
for(k=0;D[k].b!=i;k++);
D[k].a=0;
for(j=0;j<M;j++)
{
if(B[j]==D[k].b)
{
deleteDir(j,M,B);
}
}
}
int Compare(const void* a,const void* b)
{
return ((F*)b)->a-((F*)a)->a;
}
int DeletePlan(int N,int M, int K, int* A,int* B)
{
int i,s=0,t;
for(i=0;i<N;i++)
{
addFile(A[i],B);
}
for(i=0;i<M;i++)
{
D[i].b=i;
}
qsort(D,M,sizeof(F),Compare);
for(i=0;i<M;i++)
{
if(D[i].a<=K&&D[i].a!=0)
{
K-=D[i].a;
UpDelete(B[D[i].b],D[i].a,M,B);
deleteDir(D[i].b,M,B);
qsort(D,M,sizeof(F),Compare);
s++;
i=-1;
}
}
s+=K;
return s;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
944 KB |
Output is correct |
2 |
Correct |
0 ms |
944 KB |
Output is correct |
3 |
Correct |
0 ms |
944 KB |
Output is correct |
4 |
Correct |
0 ms |
944 KB |
Output is correct |
5 |
Runtime error |
0 ms |
940 KB |
SIGSEGV Segmentation fault |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
944 KB |
Output is correct |
2 |
Correct |
0 ms |
944 KB |
Output is correct |
3 |
Correct |
0 ms |
944 KB |
Output is correct |
4 |
Correct |
0 ms |
944 KB |
Output is correct |
5 |
Correct |
0 ms |
944 KB |
Output is correct |
6 |
Correct |
0 ms |
944 KB |
Output is correct |
7 |
Correct |
0 ms |
944 KB |
Output is correct |
8 |
Correct |
0 ms |
944 KB |
Output is correct |
9 |
Correct |
0 ms |
944 KB |
Output is correct |
10 |
Correct |
0 ms |
944 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
944 KB |
close (syscall #3) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |
5 |
Halted |
0 ms |
0 KB |
- |
6 |
Halted |
0 ms |
0 KB |
- |
7 |
Halted |
0 ms |
0 KB |
- |
8 |
Halted |
0 ms |
0 KB |
- |
9 |
Halted |
0 ms |
0 KB |
- |
10 |
Halted |
0 ms |
0 KB |
- |
11 |
Halted |
0 ms |
0 KB |
- |
12 |
Halted |
0 ms |
0 KB |
- |
13 |
Halted |
0 ms |
0 KB |
- |
14 |
Halted |
0 ms |
0 KB |
- |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
944 KB |
close (syscall #3) was called by the program (disallowed syscall) |
2 |
Halted |
0 ms |
0 KB |
- |
3 |
Halted |
0 ms |
0 KB |
- |
4 |
Halted |
0 ms |
0 KB |
- |
5 |
Halted |
0 ms |
0 KB |
- |
6 |
Halted |
0 ms |
0 KB |
- |
7 |
Halted |
0 ms |
0 KB |
- |
8 |
Halted |
0 ms |
0 KB |
- |
9 |
Halted |
0 ms |
0 KB |
- |
10 |
Halted |
0 ms |
0 KB |
- |
11 |
Halted |
0 ms |
0 KB |
- |
12 |
Halted |
0 ms |
0 KB |
- |
13 |
Halted |
0 ms |
0 KB |
- |
14 |
Halted |
0 ms |
0 KB |
- |
15 |
Halted |
0 ms |
0 KB |
- |