2016 CCPC-Final

时间:2023-03-09 07:05:12
2016 CCPC-Final

A.The Third Cup is Free

 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline int read()
{
int x=,f=;char ch=getchar();
while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
return x*f;
} /********************************************************************/ const int maxn = 1e5+;
int a[maxn]; bool cmp(int x, int y){
return x > y;
} int main(){
int t; t = read();
int cnt = ;
while(t--){
cnt++;
int n; n = read();
for(int i = ;i <= n;i++){
a[i] = read();
}
sort(a+, a++n, cmp);
int ans = ;
for(int i = ;i <= n;i++){
if(i% == ) continue;
ans += a[i];
}
printf("Case #%d: %d\n", cnt, ans);
}
return ;
}

B.Wash

 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll read(){
int x = , f = ; char ch = getchar();
while(ch > '' || ch < ''){if (ch == '-') f = -; ch = getchar();}
while(ch >= '' && ch <= ''){ x = x*+ch-''; ch = getchar();}
return x*f;
} /************************************************************************/ const int maxn = 1e6+;
ll c[maxn];
struct node{
ll v, base;
node(ll _v = , ll _base = ):v(_v), base(_base){}
bool operator < (const node &x) const{
return v > x.v;
}
}now, last; priority_queue<node>q1, q2; int main(){
int t; t = read();
int cnt = ;
while(t--){
while(!q1.empty()) q1.pop();
while(!q2.empty()) q2.pop();
cnt++;
int l, n, m;
l = read(); n = read(); m = read();
for(int i = ;i < n;i++){
ll x; x = read();
last.v = last.base = x;
q1.push(last);
}
for(int i = ;i < m;i++){
ll x; x = read();
last.v = last.base = x;
q2.push(last);
}
for(int i = ;i < l;i++){
last = q1.top(); q1.pop();
c[i] = last.v; //每一件洗完最小的时间
last.v += last.base;
q1.push(last);
}
ll ans = ;
for(int i = l-;i >= ;i--){
last = q2.top(); q2.pop();
ans = max(ans, last.v + c[i]);
last.v += last.base;
q2.push(last);
}
printf("Case #%d: %lld\n", cnt, ans);
}
return ;
}

L.Daylight Saving Time

 #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll read(){
int x = , f = ; char ch = getchar();
while(ch > '' || ch < ''){if (ch == '-') f = -; ch = getchar();}
while(ch >= '' && ch <= ''){ x = x*+ch-''; ch = getchar();}
return x*f;
} /************************************************************************/ int GetWeekDay(int y, int m, int d){
if(m == ) m = , y--;
if(m == ) m = , y--;
int week = (d + *m + *(m + )/ + y + y/ - y/ + y/)%;
return week;
} int t, yy, mm, dd, h, m, s, week; void solve(){
if (mm < ) printf("PST\n");
else if (mm == ){
if (week == && dd > ){
if (h == ) printf("Neither\n");
else if (h > ) printf("PDT\n");
else if (h < ) printf("PST\n");
}
else if (dd-week > ) printf("PDT\n");
else printf("PST\n");
}
else if (mm > && mm < ) printf("PDT\n");
else if (mm == ){
if (week == && dd <= ){
if (h < ) printf("PDT\n");
else if (h == ) printf("Both\n");
else printf("PST\n");
}
else if (dd - week <= ) printf("PDT\n");
else printf("PST\n");
}
else printf("PST\n");
} int main(){
t = read();
int cnt = ;
while (t--){
scanf("%d-%d-%d %d:%d:%d", &yy, &mm, &dd, &h, &m, &s);
week = GetWeekDay(yy, mm, dd);
week++;
printf("Case #%d: ", ++cnt);
solve();
}
return ;
}