Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions CodeForces/CF1741B.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#include<bits/stdc++.h>
#define int long long
#define test int t; cin>>t; while(t--)
#define ff first
#define ss second
#define vii vector<pair<int,int>>
#define vi vector<int>
#define vch vector<char>
#define pb push_back
#define all(v) v.begin(),v.end()

using namespace std;

int32_t main(){

ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);

test{
int n;
cin>>n;

if(n==3) cout<<"-1\n";
else{
vi vec(n);
int x = 1;
for(int i=(n/2); i<n; i++){
vec[i]=x;
x++;
}
for(int i=0; i<(n/2); i++){
vec[i]=x;
x++;
}

for(int i=0; i<n; i++) cout<<vec[i]<<" ";
cout<<"\n";
}
}

return 0;
}
62 changes: 62 additions & 0 deletions CodeForces/CF1741C.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include<bits/stdc++.h>
#define int long long
#define test int t; cin>>t; while(t--)
#define ff first
#define ss second
#define vii vector<pair<int,int>>
#define vi vector<int>
#define vch vector<char>
#define pb push_back
#define all(v) v.begin(),v.end()

using namespace std;

int32_t main(){

ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);

test{
int n; cin>>n;
int a[n];
for(int i=0; i<n; i++) cin>>a[i];

int thk = INT_MIN;
int thick = n;
int ans = n;
int sum = 0;

for(int i=0; i<n; i++){
thick = n;
thk = INT_MIN;
sum += a[i];

int j=0, temp, cnt;
bool psbl = 1;

while(j<n){
temp = 0, cnt=0;
while(temp<sum){
temp += a[j];
j++;
cnt++;
}

if(temp!=sum){
psbl = 0;
break;
}
thk = max(thk, cnt);
}

if(psbl) thick = thk;

ans = min(thick, ans);
}

cout<<ans<<'\n';
}

return 0;
}