Merge pull request #11 from Kiritow/master

Catch up with you~
This commit is contained in:
KiritoTRw 2016-05-26 07:47:33 +08:00
commit db7bac6f98
5 changed files with 245 additions and 0 deletions

41
QUSTOJ/1003.cpp Normal file
View File

@ -0,0 +1,41 @@
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int s, t, m, tot = 0, ans = 0;
long long l;
int vis[11000] = {0};
int sto[110] = {0};
int f[11000] = {0};
int main ()
{
//freopen ("in.txt", "r", stdin);
cin >> l >> s >> t >> m;
for (int i = 0; i < m; i++) cin >> sto[i];
sort (sto, sto + m);
if (s == t) {
for (int i = 0; i < m; i++) {
if (!(sto[i]%s)) ans++;
}
cout << ans;
return 0;
}
int e;
if (sto[0] > 100) vis[tot = 100] = 1;
else vis[tot = sto[0]] = 1;
for (int i = 1; i < m; i++) {
if ((e = sto[i] - sto[i-1]) > 100) { vis[tot += 100] = 1;}
else { vis[tot += e] = 1;}
}
for (int i = tot; i >= 0; i--) {
f[i] = 200;
for (int j = s; j <= t; j++) {
f[i] = min (f[i], f[i+j] + vis[i]);
}
}
cout << f[0];
return 0;
}

44
QUSTOJ/1443.cpp Normal file
View File

@ -0,0 +1,44 @@
#include<iostream>
using namespace std;
int m,n;
int solve()
{
int a,b,mx=0;
int i,j;
int v[61]={0},p[61]={0},q;
int v1[61]={0},v2[61]={0},p1[61]={0},p2[61]={0};
int f[50001]={0};
m/=10;
for(i=1;i<=n;i++)
{
cin>>a>>b>>q;
a/=10;
if(q!=0)
{
if(v1[q]==0){v1[q]=a;p1[q]=b;}
else {v2[q]=a;p2[q]=b;}
}
else {v[i]=a;p[i]=b;}
}
for(int i=1;i<=n;i++)
for(int j=m;j>=v[i];j--)
{
f[j]=max(f[j],f[j-v[i]]+v[i]*p[i]);
if(j-v1[i]-v[i]>=0)f[j]=max(f[j],f[j-v1[i]-v[i]]+v1[i]*p1[i]+v[i]*p[i]);
if(j-v2[i]-v[i]>=0)f[j]=max(f[j],f[j-v2[i]-v[i]]+v2[i]*p2[i]+v[i]*p[i]);
if(j-v1[i]-v2[i]-v[i]>=0)f[j]=max(f[j],f[j-v1[i]-v2[i]-v[i]]+v1[i]*p1[i]+v2[i]*p2[i]+v[i]*p[i]);
mx=max(f[j],mx);
}
cout<<mx*10<<endl;
//system("pause");
return 0;
}
int main()
{
while(cin>>m>>n)
{
solve();
}
return 0;
}

41
RQNOJ/17.cpp Normal file
View File

@ -0,0 +1,41 @@
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int s, t, m, tot = 0, ans = 0;
long long l;
int vis[11000] = {0};
int sto[110] = {0};
int f[11000] = {0};
int main ()
{
//freopen ("in.txt", "r", stdin);
cin >> l >> s >> t >> m;
for (int i = 0; i < m; i++) cin >> sto[i];
sort (sto, sto + m);
if (s == t) {
for (int i = 0; i < m; i++) {
if (!(sto[i]%s)) ans++;
}
cout << ans;
return 0;
}
int e;
if (sto[0] > 100) vis[tot = 100] = 1;
else vis[tot = sto[0]] = 1;
for (int i = 1; i < m; i++) {
if ((e = sto[i] - sto[i-1]) > 100) { vis[tot += 100] = 1;}
else { vis[tot += e] = 1;}
}
for (int i = tot; i >= 0; i--) {
f[i] = 200;
for (int j = s; j <= t; j++) {
f[i] = min (f[i], f[i+j] + vis[i]);
}
}
cout << f[0];
return 0;
}

78
VIJOS/1002_HBat.cpp Normal file
View File

@ -0,0 +1,78 @@
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int stone[1000001],map[1000001],f[1000001];
//int ans;
int w=2000;
int l,s,t,m;
int p=0,k;/*
inline void findd(int a)
{
if(ans>w)return;
if(a>=p)
{
if(ans<w)w=ans;
return;
}
int i;
for(i=a+s;i<=a+t;++i)
{
if(map[i]==1)ans++;
findd(i);
if(map[i]==1)ans--;
}
return;
}
*/
int main()
{
scanf("%d%d%d%d",&l,&s,&t,&m);
int i,j;
for(i=1;i<=m;++i)
scanf("%d",&stone[i]);
sort(stone+1,stone+m+1);
for(i=1;i<=m;++i)
{
l=stone[i]-stone[i-1];
if(l%t==0)k=t;
else k=l%t+t;
if(l<k)k=l;
p+=k;
map[p]=1;
}
for(i=1;i<=p+t;++i)
{
w=200;
for(j=i-t;j<=i-s;++j)
{
if(j>=0&&f[j]<w)w=f[j];
}
/*for(j=i-t;j>=0&&j<=i-s;++j) //把j>=0放在循环头有时候可能导致循环不进行开始的时候
{
if(f[j]<w)w=f[j];
}*/
f[i]=w+map[i];
}
w=200;
for(i=p;i<=p+t;++i)
{
if(f[i]<w)w=f[i];
}
//findd(0);
cout<<w;
return 0;
}

41
VIJOS/1002_caesar_199.cpp Normal file
View File

@ -0,0 +1,41 @@
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int s, t, m, tot = 0, ans = 0;
long long l;
int vis[11000] = {0};
int sto[110] = {0};
int f[11000] = {0};
int main ()
{
//freopen ("in.txt", "r", stdin);
cin >> l >> s >> t >> m;
for (int i = 0; i < m; i++) cin >> sto[i];
sort (sto, sto + m);
if (s == t) {
for (int i = 0; i < m; i++) {
if (!(sto[i]%s)) ans++;
}
cout << ans;
return 0;
}
int e;
if (sto[0] > 100) vis[tot = 100] = 1;
else vis[tot = sto[0]] = 1;
for (int i = 1; i < m; i++) {
if ((e = sto[i] - sto[i-1]) > 100) { vis[tot += 100] = 1;}
else { vis[tot += e] = 1;}
}
for (int i = tot; i >= 0; i--) {
f[i] = 200;
for (int j = s; j <= t; j++) {
f[i] = min (f[i], f[i+j] + vis[i]);
}
}
cout << f[0];
return 0;
}