Está en la página 1de 3

158A.

Next Round Greedy Scheduler

#include <iostream> #include <iostream>


using namespace std; using namespace std;
int main() { #include <iostream>
int n,k,fakev,fsaw,cont=0; #include <algorithm>
cin>>n; #include <vector>
cin>>k; int main() {
for(int i = 1; i<= n; i++){ int n,c,min,pos;
cin>>fakev; cin>>n>>c;
if(fakev>0){ int vek[n];
if(i<=k){ int vec[c];
fsaw=fakev; for(int j =0; j<n;j++){
cont++; vek[j]=0;
}else{ }
if(fsaw==fakev){ for(int j =0; j<c;j++){
cont++; cin>>vec[j];
} }
}
} for(int i =0; i<c;i++){
} min=vek[0];
cout<<cont; pos =0;
return 0; for(int j =1; j<n;j++){
} if(vek[j]<min){
min=vek[j];
pos=j;
}
688B. Lovely Palindromes }
if(min>0){
#include <iostream> for(int j =0; j<n;j++){
using namespace std; vek[j]=vek[j]-min;
#include <string> if(vek[j]==0 && vek[pos]<vek[j]){
int main() { pos=j;
string n; }
cin>>n; }
string ninverso; }
for(int i=0;i<n.size();i++){ vek[pos]=vec[i];
ninverso= n.substr(i,1)+ninverso; if(i==c-1){
} cout<<pos+1;
cout<<n+ninverso; }else{
return 0; cout<<pos+1<<" ";
} }
}
cout<<"\n";
return 0; int cont;
} for(int i=0; i<n;i++){
vector<int> vect (vec, vec+i+1);
h=int(sizeof(vect));
766A.Mahmoud and Longest Uncommon cont=0;
Subsequence sort (vect.begin(), vect.end(),
greater<int>());
#include <iostream> for(int pl=p; pl<n;pl++){
using namespace std; if(vect[pl]==(n-p)){
int main() { cout<<vect[pl]<<" ";
string a,b; p=p+1;
cin>>a; if(cont == h){
cin>>b; cout<<"\n";
if(a.size()>b.size()){ }
cout<<a.size(); }else{
}else{ if(vect[pl]<=(n-p)){
if(b.size()>a.size()){ cout<<"\n";
cout<<b.size(); break;
}else{ }
if(b==a){ }
cout<<"-1"; }
}else{
cout<<b.size(); }
} return 0;
} }
}
}

Other Problem

#include <iostream>
using namespace std;
#include <iostream>
#include <algorithm>
#include <vector>
int main() {
int n;
cin>>n;
int vec[n];
for(int i =0; i<n;i++){
cin>>vec[i];
}

int Q=n,p=0,h;
Programación Dinámica
// Count of solutions excluding S[j]
Cambio de moneda | DP-7 y = (j >= 1) ? table[i][j - 1] : 0;
Dado un valor N, si queremos hacer un
cambio para N centavos, y tenemos un // total count
suministro infinito de cada una de las table[i][j] = x + y;
monedas valoradas S = {S1, S2, .., Sm}, ¿de }
cuántas maneras podemos hacer el cambio? }
El orden de las monedas no importa. return table[n][m - 1];
Por ejemplo, para N = 4 y S = {1,2,3}, hay }
cuatro soluciones: {1,1,1,1}, {1,1,2}, {2,2}, {1,
3}. Por lo tanto, la salida debe ser 4. Para N = // Driver Code
10 y S = {2, 5, 3, 6}, hay cinco soluciones: int main()
{2,2,2,2,2}, {2,2,3,3}, {2,2,6}, {2,3,5} y {5,5}. {
Entonces la salida debería ser 5. int arr[] = {1, 2, 3};
int m = sizeof(arr)/sizeof(arr[0]);
// C++ program for coin change problem. int n = 4;
#include<bits/stdc++.h> cout << count(arr, m, n);
return 0;
using namespace std; }

int count( int S[], int m, int n )


{
int i, j, x, y;

// We need n+1 rows as the table


// is constructed in bottom up
// manner using the base case 0
// value case (n = 0)
int table[n + 1][m];

// Fill the enteries for 0


// value case (n = 0)
for (i = 0; i < m; i++)
table[0][i] = 1;

// Fill rest of the table entries


// in bottom up manner
for (i = 1; i < n + 1; i++)
{
for (j = 0; j < m; j++)
{
// Count of solutions including S[j]
x = (i-S[j] >= 0) ? table[i - S[j]][j] : 0;

También podría gustarte