2016 CCPC-Final

A.The Third Cup is Free

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 inline int read()
 5 {
 6     int x=0,f=1;char ch=getchar();
 7     while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
 8     while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
 9     return x*f;
10 }
11 
12 /********************************************************************/
13 
14 const int maxn = 1e5+7;
15 int a[maxn];
16 
17 bool cmp(int x, int y){
18     return x > y;
19 }
20 
21 int main(){
22     int t; t = read();
23     int cnt = 0;
24     while(t--){
25         cnt++;
26         int n; n = read();
27         for(int i = 1;i <= n;i++){
28             a[i] = read();
29         }
30         sort(a+1, a+1+n, cmp);
31         int ans = 0;
32         for(int i = 1;i <= n;i++){
33             if(i%3 == 0) continue;
34             ans += a[i];
35         }
36         printf("Case #%d: %d\n", cnt, ans);
37     }
38     return 0;
39 }
View Code

 

B.Wash

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 inline ll read(){
 5     int x = 0, f = 1; char ch = getchar();
 6     while(ch > '9' || ch < '0'){if (ch == '-') f = -1; ch = getchar();}
 7     while(ch >= '0' && ch <= '9'){ x = x*10+ch-'0'; ch = getchar();}
 8     return x*f;
 9 }
10 
11 /************************************************************************/
12 
13 const int maxn = 1e6+7;
14 ll c[maxn];
15 struct node{
16     ll v, base;
17     node(ll _v = 0, ll _base = 0):v(_v), base(_base){}
18     bool operator < (const node &x) const{
19         return v > x.v;
20     }
21 }now, last;
22 
23 priority_queue<node>q1, q2;
24 
25 int main(){
26     int t; t = read();
27     int cnt = 0;
28     while(t--){
29         while(!q1.empty()) q1.pop();
30         while(!q2.empty()) q2.pop();
31         cnt++;
32         int l, n, m;
33         l = read(); n = read(); m = read();
34         for(int i = 0;i < n;i++){
35             ll x; x = read();
36             last.v = last.base = x;
37             q1.push(last);
38         }
39         for(int i = 0;i < m;i++){
40             ll x; x = read();
41             last.v = last.base = x;
42             q2.push(last);
43         }
44         for(int i = 0;i < l;i++){
45             last = q1.top(); q1.pop();
46             c[i] = last.v;      //每一件洗完最小的时间
47             last.v += last.base;
48             q1.push(last);
49         }
50         ll ans = 0;
51         for(int i = l-1;i >= 0;i--){
52             last = q2.top(); q2.pop();
53             ans = max(ans, last.v + c[i]);
54             last.v += last.base;
55             q2.push(last);
56         }
57         printf("Case #%d: %lld\n", cnt, ans);
58     }
59     return 0;
60 }
View Code

 

L.Daylight Saving Time

 1 #include <bits/stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 inline ll read(){
 5     int x = 0, f = 1; char ch = getchar();
 6     while(ch > '9' || ch < '0'){if (ch == '-') f = -1; ch = getchar();}
 7     while(ch >= '0' && ch <= '9'){ x = x*10+ch-'0'; ch = getchar();}
 8     return x*f;
 9 }
10 
11 /************************************************************************/
12 
13 int GetWeekDay(int y, int m, int d){
14     if(m == 1) m = 13, y--;
15     if(m == 2) m = 14, y--;
16     int week = (d + 2*m + 3*(m + 1)/5 + y + y/4 - y/100 + y/400)%7;
17     return week;
18 }
19 
20 int t, yy, mm, dd, h, m, s, week;
21 
22 void solve(){
23     if (mm < 3) printf("PST\n");
24     else if (mm == 3){
25         if (week == 7 && dd > 7){
26             if (h == 2) printf("Neither\n");
27             else if (h > 2) printf("PDT\n");
28             else if (h < 2) printf("PST\n");
29         }
30         else if (dd-week > 7) printf("PDT\n");
31         else  printf("PST\n");
32     }
33     else if (mm > 3 && mm < 11) printf("PDT\n");
34     else if (mm == 11){
35         if (week == 7 && dd <= 7){
36             if (h < 1) printf("PDT\n");
37             else if (h == 1) printf("Both\n");
38             else printf("PST\n");
39         }
40         else if (dd - week <= 0) printf("PDT\n");
41         else printf("PST\n");
42     }
43     else printf("PST\n");
44 }
45 
46 int main(){
47     t = read();
48     int cnt = 0;
49     while (t--){
50         scanf("%d-%d-%d %d:%d:%d", &yy, &mm, &dd, &h, &m, &s);
51         week = GetWeekDay(yy, mm, dd);
52         week++;
53         printf("Case #%d: ", ++cnt);
54         solve();
55     }
56     return 0;
57 }
View Code

 

posted @ 2018-10-10 11:41  ouyang_wsgwz  阅读(419)  评论(0编辑  收藏  举报