1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>
#include "kanapki.h"

int main() {
 int sum = 0;
 int n = getN();
 int j = 0;
 bool stop = false;
 while(!stop) {
  stop = true;
  for(int i = j; i < n; ++i) {
   if(getTaste(i) >= 0) {
    stop = false;
    if(i % nodes == getNodeId()) {
     Put(0, fun(0, i));
    }
   }
  }
  if(getNodeId() == 0) {
   sum += max();
   int maxi = 0;
   j = maxi;
  }
 }
}