T1
赛时 pts,主要原因:
题目没读仔细,错把
如果他在 B 地连续待的时间大于等于 240 分钟,那么行程卡中就会显示他去过 B 地。根据 A 地的防控政策,如果去过 B 地,那么就会被隔离 7 天(10080 分钟)
理解成了
是如果他在 B 地连续待的时间大于等于 240 分钟,就立即返回A地,再隔离7 天。
但是实际上如果有一个任务超过了240min,就可以把剩下的任务全部干完,再返回A地。接受制裁
所以代码写错了,:
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn=1010;
int n,a[maxn];
signed main(){
freopen("isolate.in","r",stdin);
freopen("isolate.out","w",stdout);
cin >>n;
int t=0;
bool tmp=false;
for(int i=1;i<=n;i++){
cin >>a[i];
if(a[i]>=240){ //破罐子破摔
tmp=true;
}
t+=a[i];
}
if(tmp){
cout <<t+400+10080; //最后返回接受制裁
return 0;
}
int t1=0,ttt=0;
for(int i=1;i<=n;i++){
t1+=a[i];
if(t1>=240){ //马上要超时的时候回城
t1=a[i];
ttt++; //A、B之间的交通费多付一次
}
}
cout <<min(t+ttt*400,t+10080)+400;//反复回城的方法不如破罐子破摔,那还是破罐子破摔吧
return 0;
}T2
0pts
……没啥好说的,超级大粗心,我在int mmax=-1,maxp=0;之后又#define int unsigned long long
:
#include<iostream>
#define int long long
using namespace std;
const int maxn=5e6+10;
int T,m,n,k,a[maxn],b[maxn];
signed main(){
freopen("sump.in","r",stdin);
freopen("sump.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0),cout.tie(0);
cin >>T;
a[1]=1;
for(int i=1;i<=5000000;i++){
a[i]=a[i-1]+1;
if(i%1000000==0){
a[i]-=54;
}
else if(i%100000==0){
a[i]-=45;
}
else if(i%10000==0){
a[i]-=36;
}
else if(i%1000==0){
a[i]-=27;
}
else if(i%100==0){
a[i]-=18;
}
else if(i%10==0){
a[i]-=9;
}
}
for(int i=1;i<=5000000;i++){
int t=i;
b[i]=1;
while(t){
b[i]*=t%10;
t/=10;
}
}
while(T--){
cin >>m >>n >>k;
int mmax=-1,maxp=0;
for(int i=m;i<=n;i++){
if(a[i]==k){
if(b[i]>mmax){
maxp=i;
mmax=b[i];
}
}
}
cout <<maxp <<" " <<mmax <<"\n";
}
return 0;
}T3
没啥好说的,赛时A了,就是一个初一绝对值的题。
T4
0pts
难难难
赛时的时候完全想不到正解,想拿20pts也了,最绝望。
赛后知道了这道题正解是分组背包+对于每个集合再做一次dp
:
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[2010],dp[2010][1<<11];
signed main() {
freopen("select.in","r",stdin);
freopen("select.out","w",stdout);
int n,m;
cin >>n >>m;
memset(dp,0x3f,sizeof(dp));
for(int i=1; i<=n; i++) {
int b;
cin >>a[i] >>b;
dp[i][a[i]]=1;
dp[i][0]=0;
}
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= 2047; j++) {
if(dp[i-1][j] != 0x3f3f3f3f) {
dp[i][j] = min(dp[i][j],dp[i-1][j]);
dp[i][j^a[i]] = min(dp[i-1][j]+1,dp[i][j^a[i]]);
}
}
}
for(int i=2047; i>=1; i--) {
if(dp[n][i]<=m) {
cout <<i;
return 0;
}
}
return 0;
}