forked from harrypotter0/algorithms-in-python
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd60a07
commit cb9f0dd
Showing
6 changed files
with
118 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <bits/stdc++.h> | ||
// #ifdef DEMETRIO | ||
// #define deb(...) fprintf(stderr,__VA_ARGS__) | ||
// #define deb1(x) cerr << #x << " = " << x << endl | ||
// #else | ||
// #define deb(...) 0 | ||
// #define deb1(x) 0 | ||
// #endif | ||
#define pb push_back | ||
#define mp make_pair | ||
#define fst first | ||
#define snd second | ||
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i) | ||
#define SZ(x) ((int)x.size()) | ||
#define mset(a,v) memset(a,v,sizeof(a)) | ||
#define mcopy(a,b) memcpy(a,b,sizeof(a)) | ||
using namespace std; | ||
typedef long long ll; | ||
|
||
int n,k;char s[512]; | ||
int f[33][33][33][33]; | ||
|
||
void upd(int& a, int v){a=max(a,v);} | ||
|
||
int main(){ | ||
int tn; | ||
scanf("%d",&tn); | ||
while(tn--){ | ||
} | ||
return 0; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
for _ in range(int(raw_input())): | ||
n,k,b=map(int,raw_input().split()) | ||
a=map(int,raw_input().split()) | ||
a.sort() | ||
x=(a[0]*k)+b | ||
cnt=0 | ||
for i in range(1,n): | ||
if a[i]>=x: | ||
cnt+=1 | ||
x=(a[i]*k)+b | ||
print cnt+1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
const int inf = 1e9; | ||
|
||
inline void upd(int &a, int b) { | ||
a = max(a, b); | ||
} | ||
|
||
|
||
void solve(){ | ||
int n,k,arr[35][35][35][35]; | ||
cin>>k>>k; | ||
for(int i=0;i<=k+1;i++)for(int j=0;j<=k+1;j++) | ||
for(int l=0;l<=k+1;l++)for(int s=0;s<=k+1;s++) | ||
arr[i][j][l][s]= -1e9; | ||
|
||
arr[0][0][0][0]=0; | ||
|
||
string st; | ||
cin>>st; | ||
|
||
for(auto c:st) | ||
for(int i=k+1;i>=0;i--)for(int j=k+1;j>=0;j--) | ||
for(int l=k+1;l>=0;l--)for(int s=k;s>=0;s--){ | ||
if(c=='c'){ | ||
upd(arr[min(i+1,k+1)][j][l][s],arr[i][j][l][s]+1); | ||
}else | ||
if(c=='h'){ | ||
upd(arr[i][min(i+j,k+1)][l][s],arr[i][j][l][s]+1); | ||
}else | ||
if(c=='e'){ | ||
upd(arr[i][j][min(j+l,k+1)][s],arr[i][j][l][s]+1); | ||
}else | ||
if(s+l<=k){ | ||
upd(arr[i][j][l][s+l],arr[i][j][l][s]+1); | ||
} | ||
} | ||
|
||
int res=0; | ||
for (int i=0;i<=k+1;i++) for (int j=0;j<=k+1;j++) | ||
for (int l=0;l<=k+1;l++){ | ||
// if (arr[i][j][l][k]!=-1e9) | ||
upd(res,arr[i][j][l][k]); | ||
} | ||
if (res==0) | ||
cout<<-1<<'\n'; | ||
else | ||
cout<<st.size()-res<<'\n'; | ||
|
||
} | ||
|
||
int main(){ | ||
int t; | ||
cin>>t; | ||
while(t--){ | ||
solve(); | ||
} | ||
} | ||
/* | ||
5 | ||
7 3 | ||
chehefc | ||
8 4 | ||
chehefch | ||
19 24 | ||
ccccchhhhheeeeeffff | ||
20 5 | ||
echhhfhfcecfhechfcch | ||
99 27 | ||
ffhffhffcfechchccccfhhhfhhhhhhehhhehhhhheeeeefeeeeeeheeheeeeffcfffffffffffhffffchffeffcefefhhfcehfe | ||
*/ |