Submission #3731663
Source Code Expand
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define llong long long
#define fr(i,l,r) for(i=(l);i<(r);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
int main(void)
{
//変数の宣言
int n;
llong m=0;
llong a[50];
llong b[50];
//よく使う変数
int i,j,k,l;
int flag=0;
int ans=0;
int count=0;
int temp,temp1,temp2;
llong int max,min;
int len;
llong int sum=0;
//データの読み込み
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%lld",&a[i]);
}
// printf("nは%dです\n", n);
// printf("データの読み込み終了\n");
//実際の処理
for(i=0;i<n;i++){
if(i==0)min=a[0];
min = min(min,a[i]);
}
// printf("min=%d\n",min);
for(i=0;i<n;i++){
b[i]=(a[i]-min)/(n+1);
m=m+b[i];
// printf("b[%d]=%d\n",i,b[i]);
}
for(i=0;i<n;i++){
// printf("a[i]=%lld,b[i]=%lld,n=%d,m=%lld,ans=%lld\n",a[i],b[i],n,m,a[i]-b[i]*n+(m-b[i]));
a[i]=a[i]-b[i]*n+(m-b[i]);
}
/* for(i=0;i<n;i++){
printf("%lld ",a[i]);
}
printf("\n");
for(i=0;i<n;i++){
printf("%lld ",b[i]);
}
*/
for(i=0;i<n;i++){
if(i==0) max=a[0];
max=max(max,a[i]);
}
if(max>n+50){
for(i=0;i<n;i++){
a[i]=a[i]-(max-n-50);
}
m=m+(max-n-50)*n;
}
flag=1;
while(flag==1){
count++;
// printf("count=%d ",count);
// for(i=0;i<n;i++){
// printf("%lld ",a[i]);
// }
// printf("\n");
flag=0;
for(i=0;i<n;i++){
if(flag==0&&a[i]>=n){
a[i]=a[i]-n-1;
flag=1;
}
}
if(flag==1){
for(i=0;i<n;i++){
a[i]++;
}
m++;
}
}
// printf("計算部分終了\n");
//出力
printf("%lld",m);
// printf("結果の出力終了\n");
return 0;
}
Submission Info
Submission Time
2018-12-07 17:03:12+0900
Task
E - Decrease (Judge ver.)
User
rausumaru
Language
C (GCC 5.4.1)
Score
600
Code Size
1798 Byte
Status
AC
Exec Time
1 ms
Memory
128 KB
Compile Error
./Main.c: In function ‘main’:
./Main.c:31:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%d",&n);
^
./Main.c:34:3: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld",&a[i]);
^
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
600 / 600
Status
Set Name
Test Cases
Sample
example0, example1, example2, example3, example4
All
example0, example1, example2, example3, example4, maxrand0, maxrand1, maxrand2, maxrand3, maxrand4, maxrand5, maxrand6, maxrand7, maxrand8, maxrand9, rand0, rand1, rand2, rand3, rand4, rand5, rand6, rand7, rand8, rand9, small0, small1, small2, small3, small4, small5, small6, small7, small8, small9
Case Name
Status
Exec Time
Memory
example0
AC
1 ms
128 KB
example1
AC
1 ms
128 KB
example2
AC
1 ms
128 KB
example3
AC
1 ms
128 KB
example4
AC
1 ms
128 KB
maxrand0
AC
1 ms
128 KB
maxrand1
AC
1 ms
128 KB
maxrand2
AC
1 ms
128 KB
maxrand3
AC
1 ms
128 KB
maxrand4
AC
1 ms
128 KB
maxrand5
AC
1 ms
128 KB
maxrand6
AC
1 ms
128 KB
maxrand7
AC
1 ms
128 KB
maxrand8
AC
1 ms
128 KB
maxrand9
AC
1 ms
128 KB
rand0
AC
1 ms
128 KB
rand1
AC
1 ms
128 KB
rand2
AC
1 ms
128 KB
rand3
AC
1 ms
128 KB
rand4
AC
1 ms
128 KB
rand5
AC
1 ms
128 KB
rand6
AC
1 ms
128 KB
rand7
AC
1 ms
128 KB
rand8
AC
1 ms
128 KB
rand9
AC
1 ms
128 KB
small0
AC
1 ms
128 KB
small1
AC
1 ms
128 KB
small2
AC
1 ms
128 KB
small3
AC
1 ms
128 KB
small4
AC
1 ms
128 KB
small5
AC
1 ms
128 KB
small6
AC
1 ms
128 KB
small7
AC
1 ms
128 KB
small8
AC
1 ms
128 KB
small9
AC
1 ms
128 KB