Submission #835683


Source Code Expand

Copy
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;
int sqr(int x){return x*x;}
int a[SIZE];
int main(){
    DRI(N);
    REP(i,N)RI(a[i]);
    int an=2e9;
    REPP(k,-100,101){
        int me=0;
        REP(i,N){
            me+=sqr(a[i]-k);
        }
        an=min(an,me);
    }
    cout<<an<<endl;
    return 0;
}

Submission Info

Submission Time
Task C - Be Together
User dreamoon
Language C++14 (GCC 5.4.1)
Score 200
Code Size 1350 Byte
Status AC
Exec Time 4 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:33:11: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     DRI(N);
           ^
./Main.cpp:34:21: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     REP(i,N)RI(a[i]);
                     ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 4
AC × 15
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt
Case Name Status Exec Time Memory
0_000.txt AC 4 ms 256 KB
0_001.txt AC 4 ms 256 KB
0_002.txt AC 4 ms 256 KB
0_003.txt AC 4 ms 256 KB
1_004.txt AC 4 ms 256 KB
1_005.txt AC 4 ms 256 KB
1_006.txt AC 4 ms 256 KB
1_007.txt AC 4 ms 256 KB
1_008.txt AC 4 ms 256 KB
1_009.txt AC 4 ms 256 KB
1_010.txt AC 4 ms 256 KB
1_011.txt AC 4 ms 256 KB
1_012.txt AC 4 ms 256 KB
1_013.txt AC 4 ms 256 KB
1_014.txt AC 4 ms 256 KB