Advertisement
konchin_shih

rank pick point

May 24th, 2021
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. #include<vector>
  4. #include<algorithm>
  5. using namespace std;
  6. template<typename T> using V=vector<T>;
  7. template<typename T1,typename T2> using P=pair<T1,T2>;
  8. int main(){
  9.     fstream fin("input.txt",ios::in);
  10.     fstream fout("output.txt",ios::out);
  11.     V<int> v{0};
  12.     V<P<int,double>> res;
  13.     int n;
  14.     while(fin>>n)
  15.         v.emplace_back(n);
  16.     int cur_cnt=0,cur_val=-1;
  17.     for(int i=1;i<int(v.size());i++){
  18.         if(cur_val!=v[i])
  19.             cur_cnt=1,res.emplace_back(i-cur_cnt+cur_cnt/2.0,cur_val),cur_val=v[i];
  20.         else
  21.             cur_cnt++;
  22.     }
  23.     res.emplace_back(v.size()-cur_cnt+1+cur_cnt/2.0,cur_val);
  24.     for(int i=1;i<int(res.size());i++)
  25.         fout<<res[i].first<<'\t'<<res[i].second<<endl;
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement