It is a long time to see you!
I have participated in Round #109 for the first time since Round #101. I think, this round is Readforces.
A: This problem is good for grammar practice. If you can max and min from array, you can solve this problem. I accepted this (it is only AC on this contest), 488pts.
B: When I submitted first, I forget array's initialization. Resubmit twice, the source passed pretest. However , it's RE on test 19.
D: I can say nothing about this problem... Submit, pretest passed and hacked!
ox-x-,1005th/1683,488pts, Rate:1578->1501. I remained in blue barely.
[A,AC (C)]
#include<stdio.h>
int main(void){
int nowmax,nowmin,count=0,n,input;
scanf("%d",&n);
scanf("%d",&input);
nowmax=nowmin=input;
while(--n){
scanf("%d",&input);
if(nowmax<input){
nowmax=input;
count++;
}else if(nowmin>input){
nowmin=input;
count++;
}
}
printf("%d\n",count);
return 0;
}
[B,RE (C)]
#include<stdio.h>
#include<stdlib.h>
int comp(const void *p1, const void *p2) {
int n1, n2;
n1 = *((const int *)p1);
n2 = *((const int *)p2);
return n2 - n1;
}
int main(void){
unsigned int count=1,a,b,n,i=0,j,point=0;
int num[1000];
for(i=0;i<1000;i++) num[i]=0;
i=0;
scanf("%u",&n);
while(n--){
scanf("%u %u",&a,&b);
if(b){
count+=b-1;
point+=a;
}else{
num[i++]=a;
}
}
if(i!=0){
qsort(num,sizeof(int)*i,sizeof(int),comp);
for(j=0;j<count && j<i;j++) point+=num[j];
}
printf("%u\n",point);
return 0;
}
[D,TLE (Hacked,C)]
#include<stdio.h>
#include<stdlib.h>
int rel_prime(int m,int n){
if(n!=0) return rel_prime(n,m%n);
else return m==1;
}
int main(void){
int list[100000];
int nowlist=0,m,n,i,j,k,flg;
char *onoff;
char in;
int input;
scanf("%d%*c%d%*c",&n,&m);
onoff=(char *)calloc(n,sizeof(char));
onoff--;
while(m--){
scanf("%c%*c%d%*c",&in,&input);
if(in=='-'){
if(onoff[input]){
for(i=0;i<nowlist;i++){
if(list[i]!=input) continue;
list[i]=0;
onoff[input]=0;
break;
}
puts("Success");
}else{
puts("Already off");
}
}else if(in=='+'){
if(onoff[input]){
puts("Already on");
}else{
flg=1;
for(i=0;i<nowlist;i++){
if(list[i]==0) continue;
if((flg=rel_prime(input,list[i]))==0) break;
}
if(flg){
onoff[input]=1;
list[nowlist++]=input;
puts("Success");
}else{
printf("Conflict with %d\n",list[i]);
}
}
}
}
free(onoff+1);
return 0;
}
0 件のコメント:
コメントを投稿