Submission #16252

# Submission time Handle Problem Language Result Execution time Memory
16252 2015-08-18T15:07:43 Z atomzeno Friend (IOI14_friend) C++
100 / 100
43 ms 2644 KB
#include "friend.h"
#define MX 100001
int D[MX],cnt;
// Find out best sample
int findSample(int n,int confidence[],int host[],int protocol[]){
	int i;
	for(i=n;i>=0;i--){D[i]=confidence[i];}
    for(i=n-1;i>=1;i--){
        if(protocol[i]==0){
            cnt+=D[i];
            D[host[i]]-=D[i];
            D[host[i]]=D[host[i]]>0?D[host[i]]:0;
            D[i]=0;
        }
        if(protocol[i]==1){
            D[host[i]]+=D[i];
            D[i]=0;
        }
        if(protocol[i]==2){
            D[host[i]]=D[host[i]]>D[i]?D[host[i]]:D[i];
            D[i]=0;
        }
    }
    return cnt+D[0];
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2644 KB Output is correct
2 Correct 0 ms 2644 KB Output is correct
3 Correct 0 ms 2644 KB Output is correct
4 Correct 0 ms 2644 KB Output is correct
5 Correct 0 ms 2644 KB Output is correct
6 Correct 0 ms 2644 KB Output is correct
7 Correct 0 ms 2644 KB Output is correct
8 Correct 0 ms 2644 KB Output is correct
9 Correct 0 ms 2644 KB Output is correct
10 Correct 0 ms 2644 KB Output is correct
11 Correct 0 ms 2644 KB Output is correct
12 Correct 0 ms 2644 KB Output is correct
13 Correct 0 ms 2644 KB Output is correct
14 Correct 0 ms 2644 KB Output is correct
15 Correct 0 ms 2644 KB Output is correct
16 Correct 0 ms 2644 KB Output is correct
17 Correct 0 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2644 KB Output is correct
2 Correct 0 ms 2644 KB Output is correct
3 Correct 0 ms 2644 KB Output is correct
4 Correct 0 ms 2644 KB Output is correct
5 Correct 0 ms 2644 KB Output is correct
6 Correct 0 ms 2644 KB Output is correct
7 Correct 0 ms 2644 KB Output is correct
8 Correct 0 ms 2644 KB Output is correct
9 Correct 0 ms 2644 KB Output is correct
10 Correct 0 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2644 KB Output is correct
2 Correct 0 ms 2644 KB Output is correct
3 Correct 0 ms 2644 KB Output is correct
4 Correct 0 ms 2644 KB Output is correct
5 Correct 0 ms 2644 KB Output is correct
6 Correct 0 ms 2644 KB Output is correct
7 Correct 0 ms 2644 KB Output is correct
8 Correct 0 ms 2644 KB Output is correct
9 Correct 0 ms 2644 KB Output is correct
10 Correct 0 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2644 KB Output is correct
2 Correct 0 ms 2644 KB Output is correct
3 Correct 0 ms 2644 KB Output is correct
4 Correct 0 ms 2644 KB Output is correct
5 Correct 0 ms 2644 KB Output is correct
6 Correct 0 ms 2644 KB Output is correct
7 Correct 0 ms 2644 KB Output is correct
8 Correct 0 ms 2644 KB Output is correct
9 Correct 0 ms 2644 KB Output is correct
10 Correct 0 ms 2644 KB Output is correct
11 Correct 0 ms 2644 KB Output is correct
12 Correct 0 ms 2644 KB Output is correct
13 Correct 0 ms 2644 KB Output is correct
14 Correct 0 ms 2644 KB Output is correct
15 Correct 0 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2644 KB Output is correct
2 Correct 0 ms 2644 KB Output is correct
3 Correct 0 ms 2644 KB Output is correct
4 Correct 0 ms 2644 KB Output is correct
5 Correct 0 ms 2644 KB Output is correct
6 Correct 0 ms 2644 KB Output is correct
7 Correct 0 ms 2644 KB Output is correct
8 Correct 0 ms 2644 KB Output is correct
9 Correct 0 ms 2644 KB Output is correct
10 Correct 0 ms 2644 KB Output is correct
11 Correct 0 ms 2644 KB Output is correct
12 Correct 0 ms 2644 KB Output is correct
13 Correct 0 ms 2644 KB Output is correct
14 Correct 1 ms 2644 KB Output is correct
15 Correct 0 ms 2644 KB Output is correct
16 Correct 0 ms 2644 KB Output is correct
17 Correct 0 ms 2644 KB Output is correct
18 Correct 0 ms 2644 KB Output is correct
19 Correct 0 ms 2644 KB Output is correct
20 Correct 0 ms 2644 KB Output is correct
21 Correct 0 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2644 KB Output is correct
2 Correct 0 ms 2644 KB Output is correct
3 Correct 0 ms 2644 KB Output is correct
4 Correct 0 ms 2644 KB Output is correct
5 Correct 0 ms 2644 KB Output is correct
6 Correct 0 ms 2644 KB Output is correct
7 Correct 0 ms 2644 KB Output is correct
8 Correct 0 ms 2644 KB Output is correct
9 Correct 0 ms 2644 KB Output is correct
10 Correct 0 ms 2644 KB Output is correct
11 Correct 0 ms 2644 KB Output is correct
12 Correct 43 ms 2644 KB Output is correct
13 Correct 28 ms 2644 KB Output is correct
14 Correct 42 ms 2644 KB Output is correct
15 Correct 24 ms 2644 KB Output is correct