Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <queue>
- #include <math.h>
- #include <vector>
- using namespace std;
- ifstream in("input.txt");
- ofstream out("output.txt");
- main(){
- int N;
- in>>N;
- vector <double> v;
- for(int i = 0; i < N; i++){
- int app;
- in>>app;
- v.push_back(app);
- }
- double a = 0, b = 0;
- bool somma;
- while(v.size() >= 1){
- a = v.front();
- somma = false;
- b = v[v.size()-1];
- for(int i = 1; i < v.size(); i++){
- if(somma){
- a = a + v[i]/pow(2,i);
- }
- else
- a = a - v[i]/pow(2,i);
- somma = !somma;
- }
- somma = false;
- int cont = 1;
- for(int i = v.size()-2; i >= 0; i--){
- if(somma){
- b = b + v[i]/pow(2,cont);
- }
- else
- b = b - v[i]/pow(2,cont);
- somma = !somma;
- cont++;
- }
- if(a > b){
- out<<"L";
- v.erase(v.begin());
- }
- else{
- out<<"R";
- v.erase(v.end()-1);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment