寒假集训Day 5考试吃瓜记

Day 5

我们考了试,被各种dalao虐得体无完肤。

不说多了,先%一波


%%%zyl神犇拿到超高名次

%%%wey神犇大幅度失误190分吊打蒟蒻我

%%%yhb神犇考试时心态爆炸还能不垫底

%%%hkh文件名对了之后就能rank4打爆全场


我个小蒟蒻...

先把代码弄上来吧

 1 #include <bits/stdc++.h>
 2 #define fp(i,l,r) for(register int i=(l);i<=(r);++i)
 3 #define fd(i,l,r) for(register int i=(l);i>=(r);--i)
 4 using namespace std;
 5 int main(){
 6     freopen("rabbit.in","r",stdin);
 7     freopen("rabbit.out","w",stdout);
 8     float l,v1,v2,v3;
 9     scanf("%f%f%f%f",&l,&v1,&v2,&v3);
10     float tim=l/(v1+v2);
11     tim*=v3;
12     printf("%.0f",floor(tim));
13     return 0;
14 }
rabbit

很可惜啊,加上floor就能加上60分了...

 1 #include <bits/stdc++.h>
 2 #define fp(i,l,r) for(register int i=(l);i<=(r);i++)
 3 #define fd(i,l,r) for(register int i=(l);i>=(r);i--)
 4 using namespace std;
 5 int n,t;
 6 int s[10000+20],p[10000+20];
 7 inline int cmmp(int a,int b){
 8     int t;
 9     t=s[a];s[a]=s[b];s[b]=t;
10     t=p[a];p[a]=p[b];p[b]=t;
11 }
12 int sum=0;
13 int main(){
14     freopen("ioi.in","r",stdin);
15     freopen("ioi.out","w",stdout);
16     scanf("%d",&n);
17     fp(i,1,n){
18         scanf("%d%d",&s[i],&p[i]);
19     }
20     scanf("%d",&t);
21     int m;
22     int k;
23     fp(pp,1,50){
24         fp(i,1,n-1){
25             k=i;
26             fp(j,i+1,n){
27                 if(p[j]<=p[i]){
28                     k=j;
29                 }
30             }
31             if(k!=i){
32                 cmmp(i,k);
33             }
34         }
35     }
36     fp(pp,1,t){
37         scanf("%d",&m);
38         fp(i,1,n){
39             if(m>=s[i]*p[i]){
40                 m-=p[i]*s[i];
41                 sum+=s[i];
42                 //printf("%d sum:%d si:%d pi:%d money:%d
",t,sum,s[i],p[i],m);
43             }
44             else{
45                 fd(j,s[i],1){
46                     if(m>=j*p[i]){
47                         sum+=j;
48                         m-=p[i]*j;
49                         //printf("%d sum:%d si:%d count:%d money:%d
",t,sum,s[i],j,m);    
50                         break;
51                     }
52                 }
53             }
54         }
55         printf("%d
",sum);
56         sum=0;
57     }
58 }
ioi(70 points)

加1个0就可以加上30分...

 1 #include <bits/stdc++.h>
 2 #define fp(i,l,r) for(register int i=(l);i<=(r);++i)
 3 #define fd(i,l,r) for(register int i=(l);i>=(r);--i)
 4 using namespace std;
 5 long long t,rr;
 6 char ch[1000+20];
 7 char re[1000+20];
 8 long long book[1000+20]={0};
 9 long long sum=0;
10 long long rem[]={5,5,5,5,5,5,5,5,5,5,
11 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
12 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
13 5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
14 5,5,5,5,5,5,5,5,5,98,5,100,5,5,5,5,97,
15 99,5,5,5,5,96};
16 int bz[10000+20]={0};
17 inline int hnfms(int now){
18     if(re[now]=='S'){
19         sum++;
20         return 0;
21     }
22     fp(i,now+1,rr-1){
23         if(rem[re[now]]-rem[re[i]]==1&&book[i]==0){
24             book[i]=1;
25             hnfms(i);
26             book[i]=0;
27         }
28     }
29     return 0;
30 }
31 int main(){
32     freopen("hnfms.in","r",stdin);
33     freopen("hnfms.out","w",stdout);
34     scanf("%lld
",&t);
35     fp(kk,1,t){
36         gets(ch);
37         int qq=0;
38         int st=strlen(ch);
39         fp(i,0,st-1){
40             if(ch[i]=='H'||ch[i]=='N'||ch[i]=='F'||ch[i]=='M'||ch[i]=='S'){
41                 re[qq]=ch[i];
42                 qq++;
43             }
44         }
45         rr=strlen(re);
46         fp(i,0,rr-1){
47             if(re[i]=='H'){
48                 book[i]=1;
49                 hnfms(i);
50                 book[i]=0;
51             }
52         }
53         printf("%lld
",sum);
54         sum=0;
55     }
56     return 0;
57 }
hnfms(20 points)

莫名其妙地少了20分...

 1 #include <bits/stdc++.h>
 2 #define fp(i,l,r) for(register int i=(l);i<=(r);++i)
 3 #define fd(i,l,r) for(register int i=(l);i>=(r);--i)
 4 using namespace std;
 5 int n;
 6 int th[1000+20][3];
 7 inline int cmmp(int a,int b){
 8     int t;
 9     t=th[a][1];th[a][1]=th[b][1];th[b][1]=t;
10     t=th[a][2];th[a][2]=th[b][2];th[b][2]=t;
11 }
12 int main(){
13     freopen("trip.in","r",stdin);
14     freopen("trip.out","w",stdout);
15     int ll=0,mm=0,al[1000+20]={0},am[1000+20]={0},sa=0,sl=0;
16     scanf("%d",&n);
17     fp(i,1,n){
18         scanf("%d",&th[i][2]);
19         th[i][1]=i;
20     }
21     int k;
22     fp(kk,1,5){
23         fp(i,1,n-1){
24             k=i;
25             fp(j,i+1,n){
26                 if(th[j][2]<th[i][2]){
27                     k=j;
28                 }
29             }
30             if(k!=0){
31                 cmmp(i,k);
32             }
33         }
34     }
35     fd(i,n,1){
36         if(sa==0&&sl==0){
37             sl+=th[i][2];
38             al[++ll]=th[i][1];
39         }
40         else if(sa>sl){
41             sl+=th[i][2];
42             al[++ll]=th[i][1];
43         }
44         else if(sa<sl){
45             sa+=th[i][2];
46             am[++mm]=th[i][1];
47         }
48     }
49     fd(i,ll,1){
50         printf("%d ",al[i]);
51     }
52     printf("
");
53     fd(i,mm,1){
54         printf("%d ",am[i]);
55     }    
56 }
trip(10 points)

为啥别人贪心90分我一贪就只有10分...


std:

 1 #include<bits/stdc++.h>
 2 #define For(i,l,r) for(int i=(l);i<=(r);i++)
 3 #define ll long long
 4 using namespace std;
 5 
 6 struct Dealer{
 7     int s;
 8     int p;
 9     int all; 
10     bool operator < (const Dealer &d) const{
11         return p<d.p;
12     }
13     
14 }dealer[10005]; 
15 int sum_s[10005],sum_all[10005];
16 
17 int main(){
18     int n,t,m,ans,x;
19     cin>>n;
20     For(i,0,n-1){
21         Dealer &d=dealer[i];
22         scanf("%d%d",&d.s,&d.p);
23         d.all = d.s * d.p;
24     }
25     sort(dealer,dealer+n);
26     sum_all[0] = dealer[0].all;
27     sum_s[0] = dealer[0].s; 
28     For(i,1,n-1){
29         sum_all[i] = sum_all[i-1] + dealer[i].all;
30         sum_s[i] = sum_s[i-1] + dealer[i].s;
31     }
32     cin>>t;
33     For(i,1,t){
34         scanf("%d",&m);
35         x = upper_bound(sum_all,sum_all+n,m)-sum_all;
36         if (x == 0) printf("%d
",m / dealer[x].p);
37         else if(x==n) printf("%d
",sum_s[n-1]);
38         else {
39             ans = sum_s[x-1] + (m - sum_all[x-1]) / dealer[x].p;
40             printf("%d
",ans);
41         }
42     }
43     return 0;
44 }
stdioi
 1 #include<bits/stdc++.h>
 2 #define For(i,l,r) for(int i=(l);i<=(r);i++)
 3 #define ll long long
 4 using namespace std;
 5 int main(){
 6     ll T,h,n,f,m,s;
 7     char c;
 8     cin>>T;
 9     getchar();
10     h=n=f=m=s=0;
11     while((c = getchar()) != EOF){
12         switch(c){
13             case '
':cout<<s<<endl;
14                       h=n=f=m=s=0;
15                       break;
16             case 'H':h++;break;
17             case 'N':n+=h;break;
18             case 'F':f+=n;break;
19             case 'M':m+=f;break;
20             case 'S':s+=m;break;
21         }
22     } 
23     return 0;
24 }
stdhnfms
 1 #include<bits/stdc++.h>
 2 #define For(i,l,r) for(int i=(l);i<=(r);i++)
 3 #define Frd(i,l,r) for(int i=(l);i>=(r);i--)
 4 #define ll long long
 5 using namespace std;
 6 int main(){
 7     int n,sum;
 8     int w[2000],f[200000];
 9     bool Ali[2000]; 
10     cin>>n;
11     sum = 0;
12     For(i,1,n){ 
13         cin>>w[i];
14         sum += w[i];
15     }
16     memset(f,0,sizeof(f));
17     sum >>= 1;
18     f[0]=-1;                        
19     For(i,1,n)
20         Frd(j,sum-w[i],0)
21             if (f[j] && !f[j+w[i]]) f[j+w[i]]=i;                
22     while (!f[sum]) sum--;
23     memset(Ali,true,sizeof(Ali));
24     while (sum!=0){
25         Ali[f[sum]] = false;
26         sum -= w[f[sum]];
27     }  
28     For(i,1,n)
29         if (Ali[i]) cout<<i<<" ";
30     cout<<endl;
31     For(i,1,n)
32         if (!Ali[i]) cout<<i<<" "; 
33     return 0;
34 }
stdtrip

总结:

知识点:

1.小学奥数

2.贪心

3.动态规划(重点)

4.二分查找(高级算法)


s

原文地址:https://www.cnblogs.com/Fraction/p/ATestAtWinterCampOfFirstHighSchoolOfChangShaInDayFive.html