Biển quảng cáo BIENQC
Code Pascal
program bienqc;
var t1,t2,h,m,s,t,n:longint;
begin
//assign(input,'bienqc.inp');reset(input);
//assign(output,'bienqc.out');rewrite(output);
read(t1,t2,h,m); readln(s);
if (h=18)and(m=0)and(s=0) then write('S')
else if (h=6)and(m=0)and(s=0) then write('T')
else
begin
t:=(h*3600+m*60+s);
t:=t mod(t1+t2);
if t<t1 then write('S') else write('T');
end;
readln;
code C
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t1,t2,h,m,s;
cin>>t1>>t2>>h>>m>>s;
long long t;
if(h>=6 && h<18)
{
printf("T");
return 0;
}
else
{
if(h>=18 && h<=24) h-=18;
else
{
h+=6;
}
t=h*3600+m*60+s;
int i=2;
int l;
while(t>=0)
{
if(i%2==0)
{
t-=t1;
l=1;
}
else
{
t-=t2;
l=2;
}
i++;
}
if(l==1) printf("S");
if(l==2) printf("T");
}
}
GIANGDEN Giăng đèn
Code Pascal
var a:array [1..1000000] of longint;
i,n,k,j,s,max:longint;
BEGIN
readln (k,n);
j:=1;
for i:=1 to n do
begin
read (a [i]);
s:=s+a [i];
while s>k do
begin
s:=s-a [j];
inc (j);
end;
if i-j+1>max then max:=i-j+1;
end;
write (max);
END.
code c
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e6+7;
int main()
{
int res,i,n,s,j,tong;
vector <int> a(maxn);
scanf("%d%d",&s,&n);
res=0;
for (i=1; i<=n; i++) {scanf("%d",&a[i]);}
tong=0;
j=1;
for (i=1; i<=n; i++)
{
tong+=a[i];
if (tong<=s)
{
res=max(res,i-j+1);
}
else
{
while (tong>s)
{
tong-=a[j];
j++;
}
}
}
printf("%d",res);
}
Không có nhận xét nào:
Đăng nhận xét
Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.