문제 해결 - Codeforces Round #637(Div.2, A-E)
71553 단어 codeforces 경기codeforces
A . N a s t y a a n d R i c e\mathrm{A.Nastya\and\Rice } A.Nastya and Rice
난이도:\1000*1000\1000
제목 설명: 전송문
S o l\mathrm{Sol} Sol
C o d e\mathrm{Code} Code
#include
using namespace std;
inline int read()
{
int sum=0,ff=1; char ch=getchar();
while(!isdigit(ch))
{
if(ch=='-') ff=-1;
ch=getchar();
}
while(isdigit(ch))
sum=sum*10+(ch^48),ch=getchar();
return sum*ff;
}
int n,m,x,y,a,b;
int main()
{
int Q=read();
for (;Q--;)
{
n=read();
x=read();
y=read();
a=read();
b=read();
int low=x-y,high=x+y;
if(low*n<=a+b&&high*n>=a-b) puts("Yes");
else puts("No");
}
return 0;
}
B . N a s t y a a n d D o o r\mathrm{B.Nastya\and\Door } B.Nastya and Door
난이도:\1300*1300\1300
제목 설명: 전송문
S o l\mathrm{Sol} Sol
C o d e\mathrm{Code} Code
#include
#define pb push_back
using namespace std;
inline int read()
{
int sum=0,ff=1; char ch=getchar();
while(!isdigit(ch))
{
if(ch=='-') ff=-1;
ch=getchar();
}
while(isdigit(ch))
sum=sum*10+(ch^48),ch=getchar();
return sum*ff;
}
const int N=2e5+5;
int T,n,k,s[N],a[N];
int main()
{
T=read();
while(T--)
{
n=read(),k=read();
a[0]=a[n+1]=1e9+5;
for ( int i=1;i<=n;++i )
a[i]=read();
for ( int i=1;i<=n;++i)
{
s[i]=s[i-1];
if(a[i]>a[i-1]&&a[i]>a[i+1])
s[i]++;
}
int pos=0,ans=0;
for ( int i=k;i<=n;++i )
if(ans<s[i-1]-s[i-k+1]+1)
{
pos=i-k+1;
ans=s[i-1]-s[i-k+1]+1;
}
printf("%d %d
",ans,pos);
}
return 0;
}
C . N a s t y a a n d S t r a n g e G e n e r a t o r\mathrm{C.Nastya\and\Strange\Generator } C.Nastya and Strange Generator
난이도:\1500*1500\1500
제목 설명: 전송문
S o l\mathrm{Sol} Sol
#include
using namespace std;
const int N=2e5+5;
inline int read()
{
int sum=0,ff=1; char ch=getchar();
while(!isdigit(ch))
{
if(ch=='-') ff=-1;
ch=getchar();
}
while(isdigit(ch))
sum=sum*10+(ch^48),ch=getchar();
return sum*ff;
}
int a[N];
signed main()
{
int Q=read();
for (;Q--;)
{
int n=read();
int flg=0;
for ( int i=1;i<=n;i++ ) a[i]=read();
for ( int i=1;i<=n;i++ )
{
int j=i;
while(j+1<=n&&a[j+1]>a[j]) j++ ;
for ( int k=i;k<j;k++ )
if((a[k]+1)^a[k+1])
flg=1;
i=j;
}
if(flg) puts("No");
else puts("Yes");
}
return 0;
}
D . N a s t y a a n d S c o r e b o a r d\mathrm{D.Nastya\and\Scoreboard } D.Nastya and Scoreboard
난이도:\1800 * 1800\1800
제목 설명: 전송문
S o l\mathrm{Sol} Sol
C o d e\mathrm{Code} Code
#include
#define pb push_back
using namespace std;
inline int read()
{
int sum=0,ff=1; char ch=getchar();
while(!isdigit(ch))
{
if(ch=='-') ff=-1;
ch=getchar();
}
while(isdigit(ch))
sum=sum*10+(ch^48),ch=getchar();
return sum*ff;
}
const int N=2e3+5;
string s[11]=
{"1110111","0010010","1011101","1011011","0111010","1101011","1101111","1010010","1111111","1111011"};
int n,m,f[N][N],g[N][N],c[N][11],h[N];
string a[N];
inline int calc(int x,int y)
{
int gs=0;
for ( int i=0;i<7;i++ )
{
if(a[x][i]=='1'&&s[y][i]=='0') return 1e9;
else
if(a[x][i]=='0'&&s[y][i]=='1') gs++;
}
return gs;
}
int main()
{
n=read();
m=read();
memset(f,-1,sizeof(f));
int alb=0;
for ( int i=1;i<=n;i++ )
{
cin>>a[i];
for ( int j=0;j<=9;j++ )
{
int flg=1;
for ( int k=0;j<7;k++ )
if(a[i][k]!=s[j][k])
{
flg=0;
break;
}
alb|=flg;
}
}
if(!alb) return puts("-1"),0;
reverse(a+1,a+n+1);
for ( int i=1;i<=n;i++ )
{
for ( int j=0;j<=9;j++ )
c[i][j]=calc(i,j);
int flg=1;
for ( int j=0;j<=9;j++ )
if(c[i][j]!=1e9) flg=0;
if(flg) return puts("-1"),0;
}
// for ( int i=1;i<=n;i++,puts("") )
// for ( int j=0;j<=9;j++ )
// printf("c[%d][%d]=%d
",i,j,c[i][j]);
f[0][0]=1;
for ( int i=1;i<=n;i++ )
for ( int j=0;j<=m;j++ )
for ( int k=0;k<=9;k++ )
{
int cost=c[i][k];
if(j-cost<0||cost==1e9) continue;
if(~f[i-1][j-cost])
f[i][j]=1,g[i][j]=k;
}
if(!(~f[n][m])) return puts("-1"),0;
for ( int i=n;i>=1;i-- )
{
int x=g[i][m];
// printf("x=%d c[%d][%d]=%d
",x,i,x,c[i][x]);
printf("%d",x);
m-=c[i][x];
}
return 0;
}
E . N a s t y a a n d U n e x p e c t e d G u e s t\mathrm{E.Nastya\and\Unexpected\Guest } E.Nastya and Unexpected Guest
난이도:\2300*2300\2300
제목 설명: 전송문
S o l\mathrm{Sol} Sol
#include
#define pb push_back
#define int long long
using namespace std;
inline int read()
{
int sum=0,ff=1; char ch=getchar();
while(!isdigit(ch))
{
if(ch=='-') ff=-1;
ch=getchar();
}
while(isdigit(ch))
sum=sum*10+(ch^48),ch=getchar();
return sum*ff;
}
const int N=1e6+5;
const int M=1e4+5;
int n,m,d[M],R,G,dis[M][1005],ans;
deque<pair<int,int> >q;
signed main()
{
n=read();
m=read();
for ( int i=1;i<=m;i++ ) d[i]=read();
G=read();
R=read();
sort(d+1,d+m+1);
memset(dis,-1,sizeof(dis));
q.push_front(make_pair(1,0));
dis[1][0]=0;
while(!q.empty())
{
pair<int,int> v=q.front();
q.pop_front();
if(v.first>1)
{
int del=d[v.first]-d[v.first-1]+v.second;
if(del<G)
{
if(dis[v.first-1][del]<0)
{
dis[v.first-1][del]=dis[v.first][v.second];
q.push_front(make_pair(v.first-1,del));
}
}
if(del==G)
{
if(dis[v.first-1][0]<0)
{
dis[v.first-1][0]=dis[v.first][v.second]+1;
q.push_back(make_pair(v.first-1,0));
}
}
}
if(v.first<m)
{
int del=d[v.first+1]-d[v.first]+v.second;
if(del<G)
{
if(dis[v.first+1][del]<0)
{
dis[v.first+1][del]=dis[v.first][v.second];
q.push_front(make_pair(v.first+1,del));
}
}
if(del==G)
{
if(dis[v.first+1][0]<0)
{
dis[v.first+1][0]=dis[v.first][v.second]+1;
q.push_back(make_pair(v.first+1,0));
}
}
}
}
int ans=-1;
for ( int i=0;i<G;i++ )
{
if(dis[m][i]<0) continue;
int gs=dis[m][i];
int tim=1ll*gs*(R+G)+i;
if(!i&&dis[m][i]) tim-=R;
if(ans<0||ans>tim) ans=tim;
}
printf("%lld
",ans);
return 0;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Codeforces Global Round 7 문제 해결(A-D2)C o d e f o r c e s G l o b a l R o u n d 7 (A - D 2)\mathrm {Codeforces\Global\Round\7 (A-D2)} Codeforces Global Round ...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.