#include"kanapka.h" #include<iostream> #include<cstdio> #include<stdlib.h> #include<stdio.h> #include<assert.h> #include "message.h" using namespace std; int suma, naj; int main() { long long naj=0,suma=0,a=0,b=GetN()-1; for(long long x=0;a<b;x++){ if(GetTaste( a )>GetTaste( b )) { suma+=GetTaste( a ); a++; } else{ suma+=GetTaste( b ); b--; } if(naj<suma)naj=suma; } if(MyNodeId()==1)cout<<naj; }
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 26 27 28 | #include"kanapka.h" #include<iostream> #include<cstdio> #include<stdlib.h> #include<stdio.h> #include<assert.h> #include "message.h" using namespace std; int suma, naj; int main() { long long naj=0,suma=0,a=0,b=GetN()-1; for(long long x=0;a<b;x++){ if(GetTaste( a )>GetTaste( b )) { suma+=GetTaste( a ); a++; } else{ suma+=GetTaste( b ); b--; } if(naj<suma)naj=suma; } if(MyNodeId()==1)cout<<naj; } |