From c09fe70582470750210cf1f5cca3b37c253843a2 Mon Sep 17 00:00:00 2001 From: Abinash Maharana <42abinash@gmail.com> Date: Mon, 28 Oct 2019 16:49:49 +0530 Subject: [PATCH] Create 1141C - Polycarp restores permutation --- .../1141C - Polycarp restores permutation | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 CodeForces/1141C - Polycarp restores permutation diff --git a/CodeForces/1141C - Polycarp restores permutation b/CodeForces/1141C - Polycarp restores permutation new file mode 100644 index 0000000..8054cd4 --- /dev/null +++ b/CodeForces/1141C - Polycarp restores permutation @@ -0,0 +1,39 @@ +#include +using namespace std; +#define pb push_back +int main(){ + int n,max = 0,i,num; + vector ar; + map mp; + cin>>n; + ar.pb(0); + mp.insert({0,1}); + for(int i=1;i>num; + if(ar[i-1]+num>max) + {max=num+ar[i-1]; + // maxp=i; + } + if(mp.find(ar[i-1]+num)==mp.end()) + { + ar.pb(ar[i-1]+num); + mp.insert(pair(ar[i-1]+num,1)); + } + else + { + cout<<-1;return 0; + } + } + + for(i=0;in){ + cout<<-1; + return 0; + } + } + for(i=0;i