From 59ed10051386e6e04ee89faa65ec4ae84e343307 Mon Sep 17 00:00:00 2001 From: Shubham Atriwal Date: Tue, 31 Oct 2017 23:44:24 +0530 Subject: [PATCH] Create Charging the Batteries --- .../Implementation/Charging the Batteries | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 Algorithms/Implementation/Charging the Batteries diff --git a/Algorithms/Implementation/Charging the Batteries b/Algorithms/Implementation/Charging the Batteries new file mode 100644 index 0000000..dbe6d4d --- /dev/null +++ b/Algorithms/Implementation/Charging the Batteries @@ -0,0 +1,52 @@ +#include +#define pb emplace_back +using namespace std; + + +int main() { + /* Enter your code here. Read input from STDIN. Print output to STDOUT */ + int n,m,k; + cin>>n>>m>>k; + vector v; + for(int i=0;i>x>>y; + if(x==0) + { + v.pb(y); + } + else if(y==n) + { + v.pb(x+n); + + } + else if(x==n) + { + v.pb(3*n-y); + } + else + { + v.pb(4*n-x); + } + } + sort(v.begin(),v.end()); + int d=v.size(); + for(int i=0;i