submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s193483003 | p04031 | C++ | #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
vector<int> a(n);
int minimum = 100;
int maximum = -100;
for(int i = 0; i < n; i++){
cin >> a.at(i);
minimum = min(minimum, a.at(i));
maximum = max(maximum, a.at(i));
}
// cout << "maximum: " << maximum << endl;
// cout << "minimum: " << minimum << endl;
long long cost = 4000000001;
for(int i = minimum; i <= maximum; i++){
int sum = 0;
for(auto j : a){
sum += (i - j) * (i - j);
}
cost = min(cost, sum);
}
cout << cost << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:24:27: error: no matching function for call to 'min(long long int&, int&)'
24 | cost = min(cost, sum);
| ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:24:27: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
24 | cost = min(cost, sum);
| ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:24:27: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
24 | cost = min(cost, sum);
| ~~~^~~~~~~~~~~
|
s379461913 | p04031 | Java | import java.util.*;
public class Main{
public static void main(String[] arg){
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int a[] = new int[N];
double sum = 0;
double ans = 0;
double totalAns = 0;
for(int i = 0 ;i < N;i++){
a[i] = sc.nextInt();
}
for(int i = 0 ;i < N;i++){
sum += a[i];
}
sum = Math.round(sum/N);
for(int j = 0;j < N; j++){
if(a[j] != sum){
ans = Math.pow((sum - a[j]),2);
totalAns += ans;
}
}
System.out.println((int)totalAns);
}
| Main.java:25: error: reached end of file while parsing
}
^
1 error
|
s429563047 | p04031 | Java | import java.util.*;
public class Main{
public static void main(String[] arg){
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int a[] = new int[N];
double sum = 0;
double ans = 0;
double totalAns = 0;
for(int i = 0 ;i < N;i++){
a[i] = sc.nextInt();
}
for(int i = 0 ;i < N;i++){
sum += a[i];
}
sum = Math.round(sum/N);
for(int j = 0;j < N; j++){
if(a[j] != sum){
ans = Math.pow((sum - a[j]),2);
totalAns += ans;
}
}
System.out.println((int)totalAns);
}
| Main.java:25: error: reached end of file while parsing
}
^
1 error
|
s854883750 | p04031 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
int main(){
int n, a;
vector<int> v;
int avg = 0;
int sum = 0;
int i;
cin >> n;
for(i = 0; i < n; i++){
cin >> a;
avg += a;
v.push_back(a);
}
if(avg%n == 0){
avg /= n;
for(i = 0; i < n; i++){
sum += (avg - v[i]) * (avg - v[i]);
}
cout << sum << endl;
}else{
int sum2 = 0;
avg /= n;
for(i = 0; i < n; i++){
sum += (avg - v[i]) * (avg - v[i]);
}
for(i = 0; i < n; i++){
sum2 += (avg + 1 - v[i]) * (avg + 1 - v[i]);
}
cout << min(sum, sum2) << endl;
}
}
| a.cc: In function 'int main()':
a.cc:13:5: error: 'vector' was not declared in this scope
13 | vector<int> v;
| ^~~~~~
a.cc:13:5: note: suggested alternatives:
In file included from /usr/include/c++/14/vector:66,
from a.cc:3:
/usr/include/c++/14/bits/stl_vector.h:428:11: note: 'std::vector'
428 | class vector : protected _Vector_base<_Tp, _Alloc>
| ^~~~~~
/usr/include/c++/14/vector:93:13: note: 'std::pmr::vector'
93 | using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
| ^~~~~~
a.cc:13:12: error: expected primary-expression before 'int'
13 | vector<int> v;
| ^~~
a.cc:19:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
19 | cin >> n;
| ^~~
| std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:24:9: error: 'v' was not declared in this scope
24 | v.push_back(a);
| ^
a.cc:30:27: error: 'v' was not declared in this scope
30 | sum += (avg - v[i]) * (avg - v[i]);
| ^
a.cc:32:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
32 | cout << sum << endl;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:32:24: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
32 | cout << sum << endl;
| ^~~~
| std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
a.cc:37:27: error: 'v' was not declared in this scope
37 | sum += (avg - v[i]) * (avg - v[i]);
| ^
a.cc:40:32: error: 'v' was not declared in this scope
40 | sum2 += (avg + 1 - v[i]) * (avg + 1 - v[i]);
| ^
a.cc:43:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
43 | cout << min(sum, sum2) << endl;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:43:17: error: 'min' was not declared in this scope; did you mean 'std::min'?
43 | cout << min(sum, sum2) << endl;
| ^~~
| std::min
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
a.cc:43:35: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
43 | cout << min(sum, sum2) << endl;
| ^~~~
| std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
|
s667821578 | p04031 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
int a[n];
for(int i=0;i<n;i++){
cin >> a[i];
}
int q,w=1000000000;
for(int i=-100;i<101;i++){
q=0;
for(j=0;j<n;j++){
q+=(a[j]-i)*(a[j]-i);
}
w=min(w,q);
}
cout << w;
}
| a.cc: In function 'int main()':
a.cc:13:9: error: 'j' was not declared in this scope
13 | for(j=0;j<n;j++){
| ^
|
s036120197 | p04031 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
int a[n];
for(int i=0;i<n;i++){
cin >> a[i];
}
int q,w=1000000000;
for(int i=-100;i<101;i++){
q=0
for(j=0;j<n;j++){
q+=(a[j]-i)*(a[j]-i);
}
w=min(w,q);
}
cout << w;
}
| a.cc: In function 'int main()':
a.cc:12:8: error: expected ';' before 'for'
12 | q=0
| ^
| ;
13 | for(j=0;j<n;j++){
| ~~~
a.cc:13:13: error: 'j' was not declared in this scope
13 | for(j=0;j<n;j++){
| ^
|
s741615043 | p04031 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
int a[n];
for(int i=0;i<n;i++){
cin << a[i];
}
int q,w=1000000000;
for(int i=-100;i<101;i++){
q=0
for(j=0;j<n;j++){
q+=(a[j]-i)*(a[j]-i);
}
w=min(w,q);
}
cout << w;
} | a.cc: In function 'int main()':
a.cc:8:9: error: no match for 'operator<<' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'int')
8 | cin << a[i];
| ~~~ ^~ ~~~~
| | |
| | int
| std::istream {aka std::basic_istream<char>}
a.cc:8:9: note: candidate: 'operator<<(int, int)' (built-in)
8 | cin << a[i];
| ~~~~^~~~~~~
a.cc:8:9: note: no known conversion for argument 1 from 'std::istream' {aka 'std::basic_istream<char>'} to 'int'
In file included from /usr/include/c++/14/regex:68,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181,
from a.cc:1:
/usr/include/c++/14/bits/regex.h:1715:5: note: candidate: 'template<class _Ch_type, class _Ch_traits, class _Bi_iter> std::basic_ostream<_CharT, _Traits>& std::__cxx11::operator<<(std::basic_ostream<_CharT, _Traits>&, const sub_match<_Bi_iter>&)'
1715 | operator<<(basic_ostream<_Ch_type, _Ch_traits>& __os,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1715:5: note: template argument deduction/substitution failed:
a.cc:8:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
8 | cin << a[i];
| ^
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41:
/usr/include/c++/14/cstddef:125:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator<<(byte, _IntegerType)'
125 | operator<<(byte __b, _IntegerType __shift) noexcept
| ^~~~~~~~
/usr/include/c++/14/cstddef:125:5: note: template argument deduction/substitution failed:
a.cc:8:5: note: cannot convert 'std::cin' (type 'std::istream' {aka 'std::basic_istream<char>'}) to type 'std::byte'
8 | cin << a[i];
| ^~~
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/string_view:763:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, basic_string_view<_CharT, _Traits>)'
763 | operator<<(basic_ostream<_CharT, _Traits>& __os,
| ^~~~~~~~
/usr/include/c++/14/string_view:763:5: note: template argument deduction/substitution failed:
a.cc:8:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
8 | cin << a[i];
| ^
/usr/include/c++/14/bits/basic_string.h:4077:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
4077 | operator<<(basic_ostream<_CharT, _Traits>& __os,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4077:5: note: template argument deduction/substitution failed:
a.cc:8:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
8 | cin << a[i];
| ^
/usr/include/c++/14/bitset:1687:5: note: candidate: 'template<class _CharT, class _Traits, long unsigned int _Nb> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const bitset<_Nb>&)'
1687 | operator<<(std::basic_ostream<_CharT, _Traits>& __os,
| ^~~~~~~~
/usr/include/c++/14/bitset:1687:5: note: template argument deduction/substitution failed:
a.cc:8:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
8 | cin << a[i];
| ^
In file included from /usr/include/c++/14/bits/ios_base.h:46,
from /usr/include/c++/14/streambuf:43,
from /usr/include/c++/14/bits/streambuf_iterator.h:35,
from /usr/include/c++/14/iterator:66,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54:
/usr/include/c++/14/system_error:339:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const error_code&)'
339 | operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e)
| ^~~~~~~~
/usr/include/c++/14/system_error:339:5: note: template argument deduction/substitution failed:
a.cc:8:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
8 | cin << a[i];
| ^
In file included from /usr/include/c++/14/memory:80,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:56:
/usr/include/c++/14/bits/shared_ptr.h:70:5: note: candidate: 'template<class _Ch, class _Tr, class _Tp, __gnu_cxx::_Lock_policy _Lp> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const __shared_ptr<_Tp, _Lp>&)'
70 | operator<<(std::basic_ostream<_Ch, _Tr>& __os,
| ^~~~~~~~
/usr/include/c++/14/bits/shared_ptr.h:70:5: note: template argument deduction/substitution failed:
a.cc:8:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
8 | cin << a[i];
| ^
In file included from /usr/include/c++/14/istream:41,
from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:563:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, _CharT)'
563 | operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)
| ^~~~~~~~
/usr/include/c++/14/ostream:563:5: note: template argument deduction/substitution failed:
a.cc:8:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
8 | cin << a[i];
| ^
/usr/include/c++/14/ostream:573:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, char)'
573 | operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)
| ^~~~~~~~
/usr/include/c++/14/ostream:573:5: note: template argument deduction/substitution failed:
a.cc:8:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
8 | cin << a[i];
| ^
/usr/include/c++/14/ostream:579:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, char)'
579 | operator<<(basic_ostream<char, _Traits>& __out, char __c)
| ^~~~~~~~
/usr/include/c++/14/ostream:579:5: note: template argument deduction/substitution failed:
a.cc:8:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>'
8 | cin << a[i];
| ^
/usr/include/c++/14/ostream:590:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, signed char)'
590 | operator<<(basic_ostream<char, _Traits>& __out, signed char __c)
| ^~~~~~~~
/usr/include/c++/14/ostream:590:5: note: template argument deduction/substitution failed:
a.cc:8:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>'
8 | cin << a[i];
| ^
/usr/include/c++/14/ostream:595:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, unsigned char)'
595 | operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)
| ^~~~~~~~
/usr/include/c++/14/ostream:595:5: note: template argument deduction/substitution failed:
a.cc:8:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>'
8 | cin << a[i];
| ^
/usr/include/c++/14/ostream:654:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const _CharT*)'
654 | operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)
| ^~~~~~~~
/usr/include/c++/14/ostream:654:5: note: template argument deduction/substitution failed:
a.cc:8:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
8 | cin << a[i];
| ^
In file included from /usr/include/c++/14/ostream:1022:
/usr/include/c++/14/bits/ostream.tcc:307:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const char*)'
307 | operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)
| ^~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:307:5: note: template argument deduction/substitution failed:
a.cc:8:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
8 | cin << a[i];
| ^
/usr/include/c++/14/ostream:671:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const char*)'
671 | operator<<(basic_ostream<char, _Traits>& __out, const char* __s)
| ^~~~~~~~
/usr/include/c++/14/ostream:671:5: note: template argument deduction/substitution failed:
a.cc:8:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>'
8 | cin << a[i];
| ^
/usr/in |
s560646411 | p04031 | Java | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] a = new int[n];
for(int i = 0; i < n; i++) {
a[i] = sc.nextInt();
}
int ans = Integer.MAX_VALUE;
for(int t = -100; t <= 100; t++) {
int c = 0;
for(int i = 0; i < n; i++) {
c += ((a[i] - t) * (a[i] - t));
}
ans = Math.min(ans, c);
}
System.out.println(ans);
} | Main.java:20: error: reached end of file while parsing
}
^
1 error
|
s933341907 | p04031 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
int N;
cin>>N;
vector<int> a(N);
for (int i=0;i<N;i++){
cin>>a.at(i);
}
int cost=0;
for (int i=0;i<N;i++){
cost += (100-a.at(i))*(100-a.at(i));
}
for(int j=-100;j<101;j++){
for (int i=0;i<N;i++){
cost += (100-a.at(i))*(100-a.at(i));
}
if(cost>= (j-a.at(i))*(j-a.at(i))){
cost = (j-a.at(i))*(j-a.at(i));
}
}
cout<<cost<<endl;
}
| a.cc: In function 'int main()':
a.cc:19:27: error: 'i' was not declared in this scope
19 | if(cost>= (j-a.at(i))*(j-a.at(i))){
| ^
|
s435242853 | p04031 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int n, a[100], b[201], s, ans;
cin >> n;
for(int i = 0; i < n; i++)
cin >> a[i];
ans = 0;
for(int i = 0; i < n; i++)
ans = ans + a[i] * a[i];
for(int i = -100; i < 101; i++){
s = 0;
for(int j = 0; j < n; j++){
s = s + (a[j] - i) * (a[j] - i);
if(s > ans) break;
}
ans = min(ans, s);
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:20:2: error: expected '}' at end of input
20 | }
| ^
a.cc:4:11: note: to match this '{'
4 | int main(){
| ^
|
s297671889 | p04031 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int n, a[100], b[201], s, ans;
cin >> n;
for(int i = 0; i < n; i++)
cin >> a[i];
for(i = -100; i < 101; i++){
s = 0;
for(int j = 0; j < n; i++){
s = s + (a[j] - i) * (a[j] - i);
}
b[i] = s;
}
ans = b[0];
for(int i = 0; i < n; i++)
ans = min(ans, b[i]);
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:9:7: error: 'i' was not declared in this scope
9 | for(i = -100; i < 101; i++){
| ^
|
s614284043 | p04031 | C++ | package main
import (
"fmt"
)
func main() {
var n int
fmt.Scan(&n)
a := make([]int, n)
for i := 0; i < n; i++ {
fmt.Scan(&a[i])
}
ans := 1000000000
for i := -100; i <= 100; i++ {
tmp := 0
for j := 0; j < n; j++ {
x := a[j] - i
tmp += x * x
}
if tmp < ans {
ans = tmp
}
}
fmt.Println(ans)
}
| a.cc:1:1: error: 'package' does not name a type
1 | package main
| ^~~~~~~
|
s697246700 | p04031 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int N; cin>>N;
int sum=0;
vector<int> a(N);
for(int i=0;i<N;i++){
cin>>a.at(i);
sum+=a.at(i);
}
int x=sum/N;
int y=sum%N;
if(2*y>N){
x++;
}
int cost=0;
for(int i=0;i<N;i++){
cost+=(a.at(i)-x)*(a.at(i)-x);
}
cout<<cost<<endl; | a.cc: In function 'int main()':
a.cc:25:20: error: expected '}' at end of input
25 | cout<<cost<<endl;
| ^
a.cc:4:11: note: to match this '{'
4 | int main(){
| ^
|
s267650974 | p04031 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
int N,c=0,avg,count=0;
cin>>N;
vector<int>B(N);for(int i=0;i<N;i++){cin>>B[i];c+=B[i];}
sort(B.begin(),B.end());
c%2==0?avg=c/N:avg=c/N+1;
for(int i=0;i<N;i++){
count+=(
} | a.cc: In function 'int main()':
a.cc:11:1: error: expected primary-expression before '}' token
11 | }
| ^
a.cc:10:13: error: expected ')' before '}' token
10 | count+=(
| ~^
| )
11 | }
| ~
a.cc:11:2: error: expected '}' at end of input
11 | }
| ^
a.cc:3:11: note: to match this '{'
3 | int main(){
| ^
|
s587185009 | p04031 | C++ | #include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#define N 102
using namespace std;
int n;
int a[N];
int main() {
cin>>n;
for (int i=0; i < n; ++i) {
cin>>a[i];
}
int ans=INT_MAX;
for (int i= 0; i < n; ++i) {
int det=0;
for (int j = 0; j < n; ++j) {
det += (a[i]-a[j])*(a[i]-a[j]);
}
ans=min(ans, det);
}
cout<<ans<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:15:11: error: 'INT_MAX' was not declared in this scope
15 | int ans=INT_MAX;
| ^~~~~~~
a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
5 | #include <algorithm>
+++ |+#include <climits>
6 | #define N 102
|
s552057822 | p04031 | Java | import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int[] a = sc.nextInt();
for(int i=0;i<N;i++) a[i]=sc.nextInt();
int ans=100*100*100;
int tmp=0;
for(int i=-100;i<100;i++)
{
tmp=0;
for(int k=0;k<N;k++)
{
tmp+= (a[k]-i)*(a[k]-i);
}
if(tmp<ans) ans=tmp;
}
System.out.println(ans);
}
} | Main.java:7: error: incompatible types: int cannot be converted to int[]
int[] a = sc.nextInt();
^
1 error
|
s153920665 | p04031 | C++ | <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
// cin>>n>>k;
// cout<<n<<k<<endl;
//string S[100];
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int res=1000000000;
int N;cin>>N;
int st[N];
for(int i=0;i<N;i++){
cin>>st[i];
}
int ans;
for(int i=-100;i<100;i++){
ans=0;
for(int x:st){
ans+=(i-x)*(i-x);
}
res=min(res,ans);
}
cout<<res<<endl;
return 0;
} | a.cc:1:1: error: expected unqualified-id before '<' token
1 | <iostream>
| ^
In file included from /usr/include/c++/14/bits/char_traits.h:42,
from /usr/include/c++/14/string:42,
from a.cc:2:
/usr/include/c++/14/bits/postypes.h:68:11: error: 'ptrdiff_t' does not name a type
68 | typedef ptrdiff_t streamsize; // Signed integral type
| ^~~~~~~~~
/usr/include/c++/14/bits/postypes.h:41:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
40 | #include <cwchar> // For mbstate_t
+++ |+#include <cstddef>
41 |
In file included from /usr/include/c++/14/bits/char_traits.h:50:
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
In file included from /usr/include/wchar.h:35,
from /usr/include/c++/14/cwchar:44,
from /usr/include/c++/14/bits/postypes.h:40:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared
2086 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope
2087 | struct remove_extent<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid
2087 | struct remove_extent<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared
2099 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope
2100 | struct remove_all_extents<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid
2100 | struct remove_all_extents<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared
2171 | template<std::size_t _Len>
| ^~~
/usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope
2176 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^~~~
/usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^
/usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope
2202 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope
2203 | struct __attribute__((__aligned__((_Align)))) { } __align;
| ^~~~~~
/usr/include/c++/14/bits/char_traits.h:144:61: error: 'std::size_t' has not been declared
144 | compare(const char_type* __s1, const char_type* __s2, std::size_t __n);
| ^~~
/usr/include/c++/14/bits/char_traits.h:146:40: error: 'size_t' in namespace 'std' does not name a type
146 | static _GLIBCXX14_CONSTEXPR std::size_t
| ^~~~~~
/usr/include/c++/14/bits/char_traits.h:150:34: error: 'std::size_t' has not been declared
150 | find(const char_type* __s, std::size_t __n, const char_type& __a);
| ^~~
/usr/include/c++/14/bits/char_traits.h:153:52: error: 'std::size_t' has not been declared
153 | move(char_type* __s1, const char_type* __s2, std::size_t __n);
| ^~~
/usr/include/c++/14/bits/char_traits.h:156:52: error: 'std::size_t' has not been declared
156 | copy(char_type* __s1, const char_type* __s2, std::size_t __n);
| ^~~
/usr/include/c++/14/bits/char_traits.h:159:30: error: 'std::size_t' has not been declared
159 | assign(char_type* __s, std::size_t __n, char_type __a);
| ^~~
/usr/include/c++/14/bits/char_traits.h:187:59: error: 'std::size_t' has not been declared
187 | compare(const char_type* __s1, const char_type* __s2, std::size_t __n)
| ^~~
/usr/include/c++/14/bits/char_traits.h: In static member function 'static constexpr int __gnu_cxx::char_traits<_CharT>::compare(const char_type*, const char_type*, int)':
/usr/include/c++/14/bits/char_traits.h:189:17: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
189 | for (std::size_t __i = 0; __i < __n; ++__i)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/bits/char_traits.h:189:33: error: '__i' was not declared in this scope; did you mean '__n'?
189 | for (std::size_t __i = 0; __i < __n; ++__i)
| ^~~
| __n
/usr/include/c++/14/bits/char_traits.h: At global scope:
/usr/include/c++/14/bits/char_traits.h:198:31: error: 'size_t' in namespace 'std' does not name a type
198 | _GLIBCXX14_CONSTEXPR std::size_t
| |
s499725675 | p04031 | C++ | #include <bits/stdc+.h>
using namespace std;
int main(){
int n;
cin >> n;
vector<int> vec;
int tmp;
for(int i=0; i<n; i++){
cin >> tmp;
vec.push_back(tmp);
}
int ans = 100000000;
for(int i=-100; i<=100; i++){
tmp = 0;
for(auto v : vec){
tmp += pow((v-i),2);
}
ans = min(ans,tmp);
}
cout << ans << endl;
} | a.cc:1:10: fatal error: bits/stdc+.h: No such file or directory
1 | #include <bits/stdc+.h>
| ^~~~~~~~~~~~~~
compilation terminated.
|
s691550509 | p04031 | C++ | #include <algorithm>
#include <iostream>
#include <map>
#include <vector>
#define DEBUG1 false
#define DEBUG2 false
#define DEBUG3 false
#define DEBUG4 false
#define DEBUG5 false
int cost(int x, int y)
{
#if DEBUG3
std::cout << "DEBUG3: r: " << std::pow(x - y, 2) << " x: " << x << " y: " << y << std::endl;
#endif
return std::pow(x - y, 2);
}
int cost(std::vector<int>& A, int y)
{
int c = 0;
for (auto itr = A.begin(); itr != A.end(); ++itr)
{
c += cost(*itr, y);
#if DEBUG4
std::cout << "DEBUG4: c: " << c << std::endl;
#endif
}
return c;
}
int middle(int l, int r)
{
return (l - r) / 2 + r;
}
int main(void)
{
int N;
std::cin >> N;
#if DEBUG1
std::cout << "DEBUG1: N: " << N << std::endl;
#endif
std::vector<int> A;
while (N)
{
int a;
std::cin >> a;
A.push_back(a);
N--;
}
#if DEBUG2
std::cout << "DEBUG2: A:";
for (auto itr = A.begin(); itr != A.end(); ++itr)
{
std::cout << " " << *itr;
}
std::cout << std::endl;
#endif
int L = *std::min_element(A.begin(), A.end());
int R = *std::max_element(A.begin(), A.end());
int M = middle(L, R);
std::map<int, int> costs;
costs[L] = cost(A, L);
costs[R] = cost(A, R);
int c = (costs[L] < costs[R] ? costs[R] : costs[L]);
while (true)
{
if (!costs.count(M))
{
costs[M] = cost(A, M);
if (costs[M] < c)
{
c = costs[M];
}
}
else
{
break;
}
if (costs[L] < costs[R])
{
R = M;
M = middle(L, M);
}
else
{
L = M;
M = middle(M, R);
}
}
#if DEBUG5
for (auto itr = costs.begin(); itr != costs.end(); ++itr)
{
std::cout << "DEBUG5: " << itr->first << " " << itr->second << std::endl;
}
#endif
std::cout << c << std::endl;
return 0;
} | a.cc: In function 'int cost(int, int)':
a.cc:17:17: error: 'pow' is not a member of 'std'
17 | return std::pow(x - y, 2);
| ^~~
|
s097999172 | p04031 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(void) {
int n; scanf("%d", &n);
int arr[n], ans = 123456;
forn(i, n) scanf("%d", &arr[i]);
for (int i = -100; i <= 100; i++) {
i64 temp = 0;
for (int j = 0; j < n; j++) {
temp += abs(i-arr[j]) * abs(i-arr[j]);
}
ans = min(ans, temp);
}
printf("%lld\n", ans);
return 0;
} | a.cc: In function 'int main()':
a.cc:7:8: error: 'i' was not declared in this scope
7 | forn(i, n) scanf("%d", &arr[i]);
| ^
a.cc:7:3: error: 'forn' was not declared in this scope; did you mean 'fork'?
7 | forn(i, n) scanf("%d", &arr[i]);
| ^~~~
| fork
a.cc:9:5: error: 'i64' was not declared in this scope
9 | i64 temp = 0;
| ^~~
a.cc:11:7: error: 'temp' was not declared in this scope; did you mean 'tm'?
11 | temp += abs(i-arr[j]) * abs(i-arr[j]);
| ^~~~
| tm
a.cc:13:20: error: 'temp' was not declared in this scope; did you mean 'tm'?
13 | ans = min(ans, temp);
| ^~~~
| tm
|
s220173783 | p04031 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
int n,ans;
ans = 10000000;
cin >> n;
vector<int>a(n);
vector<int>b(201)
for(int i=0;i<n;i++){
cin >> a.at(i);
}
for(int i=-100;i<101;i++){
for(int j=0;j<n;j++) b.at(i) += (a.at(j)-i)*(a.at(j)-i);
}
sort(b.begin(),b.end());
cout << b.at(0) << endl;
} | a.cc: In function 'int main()':
a.cc:9:3: error: expected ',' or ';' before 'for'
9 | for(int i=0;i<n;i++){
| ^~~
a.cc:9:15: error: 'i' was not declared in this scope
9 | for(int i=0;i<n;i++){
| ^
|
s566640297 | p04031 | C++ | #include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)
int int_len(int n) {
int s=0;
while(n!=0) s++, n/=10;
return s;
}
int int_sum(int n) {
int m=0,s=0,a=n;
while(a!=0) s++, a/=10;
for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
return m;
}
int gcd(int a,int b)
{
int r, tmp;
/* 自然数 a > b を確認・入替 */
if(a<b){
tmp = a;
a = b;
b = tmp;
}
/* ユークリッドの互除法 */
r = a % b;
while(r!=0){
a = b;
b = r;
r = a % b;
}
return b;
}
int fac(int n){
int m=1;
while(n>=1) m*=n,n--;
return m;
}
int vec_sum(vector<int> v){
int n=0;
for(int i=0;i<v.size();i++) n+=v[i];
return n;
}
///////////////////////////
int main() {
int n;
cin>>n;
vector<int> v(n);
rep(i,n) cin>>v[i];
int cnt1=vec_sum(v)/n;
int cnt2=ans1+1;
int ans1=0,ans2=0;
rep(i,n){
ans1+=(int)pow(abs(v[i]-cnt1),2);
ans2+=(int)pow(abs(v[i]-cnt2),2);
}
cout<<min(ans1,ans2)<<endl;
}
/////////////////////////// | a.cc: In function 'int main()':
a.cc:75:12: error: 'ans1' was not declared in this scope
75 | int cnt2=ans1+1;
| ^~~~
|
s818214728 | p04031 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
const int INF=1001001001;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define MOD 1000000007
#define EPS 10e-8
int gcd(int a,int b){return b?gcd(b,a%b):a;} //最大公約数
int lcm(int a, int b) {return a * b / gcd(a, b);} //最小公倍数
int main(){
int n;
cin >> n;
float a[n];
float cnt = 0.0;
rep(i, n)
{
cin >> a[i];
cnt+=a[i];
}
cnt = round(cnt / n);
ll ans = 0;
rep(i,n){
ans += pow(a[i]-cnt,2.0);
}
cout << ans << endl;z
} | a.cc: In function 'int main()':
a.cc:28:25: error: 'z' was not declared in this scope
28 | cout << ans << endl;z
| ^
|
s674683953 | p04031 | Java | import java.util.*;
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int[] a = new int[N];
int min = 0;
int max = 0;
int sum = 0;
int ans = 10000000000000;
for(int i = 0 ; i < N ; i++){
a[i] = sc.nextInt();
min = a[0];
max = a[0];
if(min > a[i]){
min = a[i];
}
if(max < a[i]){
max = a[i];
}
}
for(int j = min ; j <= max ; j ++){
sum = 0;
for (int i = 0 ; i < N ; i++){
sum = sum + (a[i] - j) * (a[i] - j) ;
}
if(ans > sum){
ans = sum;
}
}
System.out.println(ans);
}
} | Main.java:13: error: integer number too large
int ans = 10000000000000;
^
1 error
|
s052342627 | p04031 | Java | import java.util.*;
import java.util.Arrays;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int[] a = new int[N];
int min = 0;
int max = 0;
int sum = 0;
int ans = 10000000000000;
for(int i = 0 ; i < N ; i++){
a[i] = sc.nextInt();
min = a[0];
max = a[0];
if(min > a[i]){
min = a[i];
}
if(max < a[i]){
max = a[i];
}
}
for(int j = min ; j <= max ; j ++){
sum = 0;
for (int i = 0 ; i < N ; i++){
sum = sum + (a[i] - j) * (a[i] - j) ;
}
if(ans > sum){
ans = sum;
}
}
System.out.println(ans);
}
} | Main.java:13: error: integer number too large
int ans = 10000000000000;
^
1 error
|
s592456570 | p04031 | C++ | #include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)
int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// --------------------------------------
int n;
int a[101];
int cal(int mi) {
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n;
REP(i, n) {
cin >> a[i];
}
int ans = INF;
if(a[0] == a[n-1]) ans = 0;
FOR(i, -100, 100) {
ll sum = 0;
REP(j, n) {
sum += ((a[j] - i) * (a[j] - i));
}
ans = min(sum, ans);
sum = 0;
}
cout << ans << endl;
}
| a.cc: In function 'int cal(int)':
a.cc:40:1: warning: no return statement in function returning non-void [-Wreturn-type]
40 | }
| ^
a.cc: In function 'int main()':
a.cc:59:14: error: no matching function for call to 'min(ll&, int&)'
59 | ans = min(sum, ans);
| ~~~^~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:59:14: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
59 | ans = min(sum, ans);
| ~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:8:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:59:14: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
59 | ans = min(sum, ans);
| ~~~^~~~~~~~~~
|
s863448347 | p04031 | C++ | #include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)
int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// --------------------------------------
int n;
int a[101];
int cal(int mi) {
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n;
REP(i, n) {
cin >> a[i];
}
int ans = INF;
if(s[0] == s[n-1]) ans = 0;
FOR(i, -100, 100) {
ll sum = 0;
REP(j, n) {
sum += ((a[j] - i) * (a[j] - i));
}
ans = min(sum, ans);
sum = 0;
}
cout << ans << endl;
}
| a.cc: In function 'int cal(int)':
a.cc:40:1: warning: no return statement in function returning non-void [-Wreturn-type]
40 | }
| ^
a.cc: In function 'int main()':
a.cc:53:6: error: 's' was not declared in this scope
53 | if(s[0] == s[n-1]) ans = 0;
| ^
a.cc:59:14: error: no matching function for call to 'min(ll&, int&)'
59 | ans = min(sum, ans);
| ~~~^~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:59:14: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
59 | ans = min(sum, ans);
| ~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:8:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:59:14: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
59 | ans = min(sum, ans);
| ~~~^~~~~~~~~~
|
s823989317 | p04031 | Java | import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;
class FastScanner {
private final InputStream in = System.in;
private final byte[] buffer = new byte[1024];
private int ptr = 0;
private int buflen = 0;
private boolean hasNextByte() {
if (ptr < buflen) {
return true;
} else {
ptr = 0;
try {
buflen = in.read(buffer);
} catch (IOException e) {
e.printStackTrace();
}
if (buflen <= 0) {
return false;
}
}
return true;
}
private int readByte() {
if (hasNextByte())
return buffer[ptr++];
else
return -1;
}
private static boolean isPrintableChar(int c) {
return 33 <= c && c <= 126;
}
public boolean hasNext() {
while (hasNextByte() && !isPrintableChar(buffer[ptr]))
ptr++;
return hasNextByte();
}
public String next() {
if (!hasNext())
throw new NoSuchElementException();
StringBuilder sb = new StringBuilder();
int b = readByte();
while (isPrintableChar(b)) {
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
public long nextLong() {
if (!hasNext())
throw new NoSuchElementException();
long n = 0;
boolean minus = false;
int b = readByte();
if (b == '-') {
minus = true;
b = readByte();
}
if (b < '0' || '9' < b) {
throw new NumberFormatException();
}
while (true) {
if ('0' <= b && b <= '9') {
n *= 10;
n += b - '0';
} else if (b == -1 || !isPrintableChar(b)) {
return minus ? -n : n;
} else {
throw new NumberFormatException();
}
b = readByte();
}
}
public int nextInt() {
long nl = nextLong();
if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
throw new NumberFormatException();
return (int) nl;
}
public double nextDouble() {
return Double.parseDouble(next());
}
}
public class Main {
static int[] w = new int[100010];
static int[] v = new int[100010];
static int[][] dp = new int[110][100010];
static int k;
static int chmin(int a, int b) {
if (a > b) {
a = b;
return a;
}
return a;
}
static int chmax(int a, int b) {
if (a < b) {
a = b;
return a;
}
return a;
}
public static void main(String[] args) {
FastScanner fs = new FastScanner();
int n = fs.nextInt();
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = fs.nextInt();
}
int minCount = 101;
int tmpCount = 0;
for (int j = -100; j <= 100; j++) {
tmpCount = 0;
for (int i = 0; i < n; i++) {
if (a[i] != j)
tmpCount += Math.pow(a[i] - j, 2);
}
minCount = Math.min(minCount, tmpCost);
}
System.out.println(minCount);
}
}
| Main.java:134: error: cannot find symbol
minCount = Math.min(minCount, tmpCost);
^
symbol: variable tmpCost
location: class Main
1 error
|
s145007161 | p04031 | C++ | #include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;
int main()
{
int N:
cin >> N;
vector<int> a;
for (int i = 0; i < N; i++) {
int _a;
cin >> _a;
a.push_back(_a);
}
int min_cost = 1000000000;
for (int y = -100; y <= 100; y++) {
int cost = 0;
for (int i = 0; i < N; i++) {
cost += (a[i] - y) * (a[i] - y);
}
min_cost = min(cost, min_cost);
}
cout << min_cost << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:20:10: error: found ':' in nested-name-specifier, expected '::'
20 | int N:
| ^
| ::
a.cc:20:9: error: 'N' has not been declared
20 | int N:
| ^
a.cc:21:9: error: qualified-id in declaration before '>>' token
21 | cin >> N;
| ^~
a.cc:23:26: error: 'N' was not declared in this scope
23 | for (int i = 0; i < N; i++) {
| ^
a.cc:32:29: error: 'N' was not declared in this scope
32 | for (int i = 0; i < N; i++) {
| ^
|
s515750718 | p04031 | C++ | #include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>
#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
int main()
{
int n;
cin >> n;
vi va(n);
REP(i, n) cin >> va[i];
int best = 10000000;
REP1C(1, 100)
{
int tmp = 0;
REP(i, n)
tmp += (tmp - va[i]) * (tmp - va[i]);
chmin(best, tmp);
}
cout << best << endl;
}
| a.cc: In function 'int main()':
a.cc:57:15: error: expected unqualified-id before numeric constant
57 | REP1C(1, 100)
| ^
a.cc:18:28: note: in definition of macro 'REP1C'
18 | #define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
| ^
a.cc:57:15: error: expected ';' before numeric constant
57 | REP1C(1, 100)
| ^
a.cc:18:28: note: in definition of macro 'REP1C'
18 | #define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
| ^
a.cc:18:29: error: expected ';' before '{' token
18 | #define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
| ^
a.cc:57:9: note: in expansion of macro 'REP1C'
57 | REP1C(1, 100)
| ^~~~~
a.cc:18:29: error: expected primary-expression before '{' token
18 | #define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
| ^
a.cc:57:9: note: in expansion of macro 'REP1C'
57 | REP1C(1, 100)
| ^~~~~
a.cc:18:29: error: expected ')' before '{' token
18 | #define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
| ~ ^
a.cc:57:9: note: in expansion of macro 'REP1C'
57 | REP1C(1, 100)
| ^~~~~
a.cc:18:33: error: expected ';' before '}' token
18 | #define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
| ^
a.cc:57:9: note: in expansion of macro 'REP1C'
57 | REP1C(1, 100)
| ^~~~~
a.cc:57:15: error: lvalue required as increment operand
57 | REP1C(1, 100)
| ^
a.cc:18:51: note: in definition of macro 'REP1C'
18 | #define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
| ^
|
s637052354 | p04031 | C++ | #include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main()
{
long long int n, d, sumA = 0, sumB = 0, midA, midB = 1e7;
cin >> n;
vector<long long int> v;
for (long long int i = 0; i < n; i++)
{
cin >> d;
v.push_back(d);
}
v.resize(n);
if (n == 1)
{
cout << 0;
return 0;
}
sort(v.begin(), v.end());
midA = (v[0] + v[n - 1]) / 2;
if ((v[0] + v[n - 1]) % 2)
midB = (v[0] + v[n - 1]) / 2 + 1;
for (long long int i = 0; i < n; i++)
{
sumA += pow(midA - v[i], 2);
if (midB != 1e7)
sumB += pow(midB - v[i], 2);
}
cout << ((midB == 1e7) ? sumA : min(sumA, sumB)) ;
return 0;
}
| a.cc: In function 'int main()':
a.cc:22:3: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
22 | sort(v.begin(), v.end());
| ^~~~
| sqrt
|
s256174168 | p04031 | C++ | #include <iostream>
#include <cmath>
using namespace std;
int main ()
{
int n;
cin>>n;
int a[102];
long long sum=0;
for (int i=1;i<=n;i++){
cin>>a[i];
sum+=a[i];
}
long long j=round(double(sum)/n);
int o=0;
for (int i=1;i<=n;i++){
o+=(a[i]-j)*(a[i]-j);
}
cout<<o;
| a.cc: In function 'int main()':
a.cc:19:9: error: expected '}' at end of input
19 | cout<<o;
| ^
a.cc:5:1: note: to match this '{'
5 | {
| ^
|
s128913458 | p04031 | C++ | #include <iostream>
using namespace std;
int main ()
{
int n;
cin>>n;
int a[n];
int sum=0;
for (int i=1;i<=n;i++){
cin>>a[i];
sum+=a[i];
}
int j=round(sum/n);
int o=0;
for (int i=1;i<=n;i++){
o+=(a[i]-j)*(a[i]-j);
}
cout<<o;
} | a.cc: In function 'int main()':
a.cc:13:7: error: 'round' was not declared in this scope
13 | int j=round(sum/n);
| ^~~~~
|
s751930549 | p04031 | Java | import java.util.*;
class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int N = Integer.parseInt(sc.next());
int max = 0;
int min = 0;
int ans = 100;
ArrayList<Integer> ary = new ArrayList<Integer>();
for(int i = 0; i < N; i ++) {
ary.add(Integer.parseInt(sc.next()));
}
max = Collections.max(ary);
min = Collections.min(ary);
for(int i = min; i <= max; i++) {
int x = 0;
for(int y = 0;y < ary.size(); y++) {
x += (ary.get(y) - i) * (ary.get(y) - i);
}
ans = Math.min(cost, cost_);
}
System.out.println(ans);
}
} | Main.java:23: error: cannot find symbol
ans = Math.min(cost, cost_);
^
symbol: variable cost
location: class Main
Main.java:23: error: cannot find symbol
ans = Math.min(cost, cost_);
^
symbol: variable cost_
location: class Main
2 errors
|
s726876200 | p04031 | C++ | #include <iostream>
using namespace std;
int n;
int a[210];
int minu=0, maxi=0;
int minute() {
int min = 1000;
for (int i = 0; i < n; i++) {
if (a[i] < min) {
min = a[i];
}
}
return min;
}
int maximum() {
int max = -1000;
for (int i = 0; i < n; i++) {
if (a[i] > max) {
max = a[i];
}
}
return max;
}
int main() {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
minu = minute();
maxi = maximum();
//cout << minu << " " << maxi << endl;
double ans = 0;
double min = 10000000;
if (minu == maxi) {
cout << 0 << endl;
return 0;
}
for (int i = minu; i <= maxi; i++) {
for (int j = 0; j < n; j++) {
ans += pow((double)a[j] - i, 2.0);
}
if (ans < min) min = ans;
ans = 0;
}
cout << min << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:44:32: error: 'pow' was not declared in this scope
44 | ans += pow((double)a[j] - i, 2.0);
| ^~~
|
s774256415 | p04031 | C++ | using namespace std;
int main(){
int n;
cin>>n;
vector<int> a(n);
for(int i=0;i<n;i++){
cin>>a[i];
}
a.push_back(-1777);
sort(a.begin(),a.end());
int s=0;
int c=0;
for(int i=1;i<=n;i++){
if(a[i-1]!=a[i]){
s+=a[i];
c++;
}
}
if(s%c>=c/2){
s=s/c+1;
}
else {
s/=c;
}
int ans=0;
for(int i=1;i<=n;i++){
ans+=(a[i]-s)*(a[i]-s);
}
cout<<ans<<endl;
}
| a.cc: In function 'int main()':
a.cc:4:3: error: 'cin' was not declared in this scope
4 | cin>>n;
| ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
+++ |+#include <iostream>
1 | using namespace std;
a.cc:5:3: error: 'vector' was not declared in this scope
5 | vector<int> a(n);
| ^~~~~~
a.cc:1:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
+++ |+#include <vector>
1 | using namespace std;
a.cc:5:10: error: expected primary-expression before 'int'
5 | vector<int> a(n);
| ^~~
a.cc:7:10: error: 'a' was not declared in this scope
7 | cin>>a[i];
| ^
a.cc:9:3: error: 'a' was not declared in this scope
9 | a.push_back(-1777);
| ^
a.cc:10:3: error: 'sort' was not declared in this scope; did you mean 'short'?
10 | sort(a.begin(),a.end());
| ^~~~
| short
a.cc:29:3: error: 'cout' was not declared in this scope
29 | cout<<ans<<endl;
| ^~~~
a.cc:29:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:29:14: error: 'endl' was not declared in this scope
29 | cout<<ans<<endl;
| ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
+++ |+#include <ostream>
1 | using namespace std;
|
s250256164 | p04031 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
vector<int> a(n);
for(int i=0;i<n;i++){
cin>>a[i];
}
a.push_back(-1777);
sort(a.begin(),a.end());
int s=0;
int c=0;
for(int i=1;i<=n;i++){
if(a[i-1]!=a[i]){
s+=a[i];
c++;
}
}
s/=c;
int ans=0;
for(int i=1;i<=n;i++){
ans+=(a[i]-s)*(a[i]-s)
}
cout<<ans<<endl;
} | a.cc: In function 'int main()':
a.cc:23:27: error: expected ';' before '}' token
23 | ans+=(a[i]-s)*(a[i]-s)
| ^
| ;
24 | }
| ~
|
s308665069 | p04031 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
double n;
cin >> n;
vector<double> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
double sum = 0;
for (int i = 0; i < n; i++) {
sum += a[i];
}
int ave = round(sum / n);
int ans = 0;
for (int i = 0; i < n; i++) {
ans += abs(a[i] - ave)*abs(a[i] - ave);
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:18:19: error: 'round' was not declared in this scope
18 | int ave = round(sum / n);
| ^~~~~
|
s392698218 | p04031 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >> n;
int sum;
vector<int>q;
for(int i=0; i<n; ++i){
int a;
cin >> a;
q.push_back(a);
sum += a;
}
int mean=int(sum/n+0.5);
int res =0;
int abs1=0;
for(int i=0; i<n; ++i)
abs1 = abs(q[i]-mean);
int b = abs1 * abs1;
res += abs1;}
cout << res << endl;
}
| a.cc:24:3: error: 'cout' does not name a type
24 | cout << res << endl;
| ^~~~
a.cc:25:1: error: expected declaration before '}' token
25 | }
| ^
|
s976315494 | p04031 | C++ | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll lcm(ll a, ll b) { return (a / __gcd(a, b) * b); }
int main() {
//
int n;
cin >> n;
ll ans = INT_MAX;
vi a(n);
rep(i, n) cin >> a[i];
REP(x, -100, 101) {
ll total = 0;
rep(i, n) { total += (x - a[i]) * (x - a[i]); }
ans = min(total, ans);
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:36:12: error: 'INT_MAX' was not declared in this scope
36 | ll ans = INT_MAX;
| ^~~~~~~
a.cc:15:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
14 | #include <unordered_set>
+++ |+#include <climits>
15 | #include <vector>
|
s864332634 | p04031 | C++ |
#include <iostream>
#include <vector>
#include <numeric>
#include <functional>
using namespace std;
int main() {
int n;
cin >> n;
auto v = vector<int>(n);
for (int i = 0; i < n; i++)
cin >> v[i];
int avg = round(accumulate(v.begin(), v.end(), 0, plus<int>()) / (double)n);
cout << avg << endl;
cout << accumulate(v.begin(), v.end(), 0, [avg](auto acc, auto x) {
return acc + (avg - x) * (avg - x);
}) << endl;
}
| a.cc: In function 'int main()':
a.cc:14:19: error: 'round' was not declared in this scope
14 | int avg = round(accumulate(v.begin(), v.end(), 0, plus<int>()) / (double)n);
| ^~~~~
|
s522789562 | p04031 | C++ | #include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include <array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
//AtCoderC++.cpp
using namespace std;
int main() {
int N; cin >> N;
auto sum = 0.0;
auto as = vector<int>(N);
for (size_t i = 0; i < N; i++) {
cin >> as[i];
sum += as[i];
}
int average = round(sum / N);
int answer = 0;
for (size_t i = 0; i < N; i++) {
answer += (as[i] - average)*(as[i] - average);
}
cout << answer << endl;
} | a.cc: In function 'int main()':
a.cc:23:23: error: 'round' was not declared in this scope
23 | int average = round(sum / N);
| ^~~~~
|
s267788480 | p04031 | C++ | #include <bits/stdc++.h>
using namespace std;
int cost_function(int val1,int val2){
int val = val1-val2;
return val*val;
}
int main() {
int n; cin>>n;
int a[n+2];
bool allEq = true;
for(int i=0;i<n;i++) {
cin>>a[i];
if(!allEq) continue;
if(i>0){
if(a[i]!=a[i-1]) allEq = false;
}
}
if(allEq) {
printf("0\n"); return 0;
}
int minTotalCost = INT_MAX;
for(int num = -100; num<=100;num++){
int cost = 0;
for(int i=0;i<n;i++) cost+=cost_function(num,a[i]);
minTotalCost = min(minTotalCost, cost);
}
printf("%d\n", minTotalCost);
return 0;
}#include <bits/stdc++.h>
using namespace std;
int cost_function(int val1,int val2){
int val = val1-val2;
return val*val;
}
int main() {
int n; cin>>n;
int a[n+2];
bool allEq = true;
for(int i=0;i<n;i++) {
cin>>a[i];
if(!allEq) continue;
if(i>0){
if(a[i]!=a[i-1]) allEq = false;
}
}
if(allEq) {
printf("0\n"); return 0;
}
int minTotalCost = INT_MAX;
for(int num = -100; num<=100;num++){
int cost = 0;
for(int i=0;i<n;i++) cost+=cost_function(num,a[i]);
minTotalCost = min(minTotalCost, cost);
}
printf("%d\n", minTotalCost);
return 0;
} | a.cc:31:2: error: stray '#' in program
31 | }#include <bits/stdc++.h>
| ^
a.cc:31:3: error: 'include' does not name a type
31 | }#include <bits/stdc++.h>
| ^~~~~~~
a.cc:33:5: error: redefinition of 'int cost_function(int, int)'
33 | int cost_function(int val1,int val2){
| ^~~~~~~~~~~~~
a.cc:3:5: note: 'int cost_function(int, int)' previously defined here
3 | int cost_function(int val1,int val2){
| ^~~~~~~~~~~~~
a.cc:37:5: error: redefinition of 'int main()'
37 | int main() {
| ^~~~
a.cc:7:5: note: 'int main()' previously defined here
7 | int main() {
| ^~~~
|
s394361006 | p04031 | C++ | #include <cstdio>
using namespace std;
int main() {
int n;
scanf("%d", &n);
int a[100];
for (int i=0; i<n; ++i)
scanf("%d", &a[i]);
int ans = 100000;
for (int i=-100; i<=100; i++) {
int sum = 0;
for (int j=0; j<N; ++j){
sum += (a[j]-i)*(a[j]-i);
}
if (ans > sum)
ans = sum;
}
printf("%d\n", ans);
return 0;
} | a.cc: In function 'int main()':
a.cc:15:25: error: 'N' was not declared in this scope
15 | for (int j=0; j<N; ++j){
| ^
|
s014258960 | p04031 | C++ | #include <cstdio>
using namespace std;
int main() {
int n;
scanf("%d", &n);
int a[100];
for (int i=0; i<N; ++i)
scanf("%d", &a[i]);
int ans = 100000;
for (int i=-100; i<=100; i++) {
int sum = 0;
for (int j=0; j<N; ++j){
sum += (a[j]-i)*(a[j]-i);
}
if (ans > sum)
ans = sum;
}
printf("%d\n", ans);
return 0;
} | a.cc: In function 'int main()':
a.cc:9:21: error: 'N' was not declared in this scope
9 | for (int i=0; i<N; ++i)
| ^
a.cc:15:25: error: 'N' was not declared in this scope
15 | for (int j=0; j<N; ++j){
| ^
|
s161764669 | p04031 | C++ | #include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
#define repprev(i,a,b) for(ll i=b-1;i>=a;i--)
#define reprev(i,n) repprev(i,0,n)
using namespace std;
#define sz(x) ((int)(x).size())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MEMSET(v, h) memset((v), h, sizeof(v))
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T> int former(const vector<T> &v, T x){
return upper_bound(v.begin(),v.end(),x) - v.begin() - 1;
}
template<class T> int latter(const vector<T> &v, T x){
return lower_bound(v.begin(),v.end(),x) - v.begin();
}
#define pb push_back
#define mp make_pair
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define BIT_FLAG_0 (1<<0) // 0000 0000 0000 0001
#define BIT_FLAG_1 (1<<1) // 0000 0000 0000 0010
#define BIT_FLAG_2 (1<<2) // 0000 0000 0000 0100
#define BIT_FLAG_3 (1<<3) // 0000 0000 0000 1000
#define BIT_FLAG_4 (1<<4) // 0000 0000 0001 0000
#define BIT_FLAG_5 (1<<5) // 0000 0000 0010 0000
#define BIT_FLAG_6 (1<<6) // 0000 0000 0100 0000
#define BIT_FLAG_7 (1<<7) // 0000 0000 1000 0000
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const ll LLINF = 1LL<<60;
const int INTINF = 1<<30;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++){
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
long long COM(int n, int k){
if (n < k) return 0;
if (n < 0 || k < 0) return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct UnionFind {
vector<ll> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2
UnionFind(ll n) : par(n, -1) { }
void init(ll n) { par.assign(n, -1); }
ll root(ll x) {
if (par[x] < 0) return x;
else return par[x] = root(par[x]);
}
bool issame(ll x, ll y) {
return root(x) == root(y);
}
bool merge(ll x, ll y) {
x = root(x); y = root(y);
if (x == y) return false;
if (par[x] > par[y]) swap(x, y); // merge technique
par[x] += par[y];
par[y] = x;
return true;
}
ll size(ll x) {
return -par[root(x)];
}
};
template <typename T>
vector<T> dijkstra(int s,vector<vector<pair<int, T> > > & G){
const T INF = numeric_limits<T>::max();
using P = pair<T, int>;
int n=G.size();
vector<T> d(n,INF);
vector<int> b(n,-1);
priority_queue<P,vector<P>,greater<P> > q;
d[s]=0;
q.emplace(d[s],s);
while(!q.empty()){
P p=q.top();q.pop();
int v=p.second;
if(d[v]<p.first) continue;
for(auto& e:G[v]){
int u=e.first;
T c=e.second;
if(d[u]>d[v]+c){
d[u]=d[v]+c;
b[u]=v;
q.emplace(d[u],u);
}
}
}
return d;
}
vector<vector<int> > bfs(vector<string> &s,int sy,int sx,char wall,int dir){
int h=s.size(),w=s.front().size();
vector<vector<int> > dp(h,vector<int>(w,-1));
using P = pair<int, int>;
queue<P> q;
dp[sy][sx]=0;
q.emplace(sy,sx);
int dy[]={1,-1,0,0,1,1,-1,-1};
int dx[]={0,0,1,-1,1,-1,1,-1};
auto in=[&](int y,int x){return 0<=y&&y<h&&0<=x&&x<w;};
while(!q.empty()){
int y,x;
tie(y,x)=q.front();q.pop();
for(int k=0;k<dir;k++){
int ny=y+dy[k],nx=x+dx[k];
if(!in(ny,nx)||s[ny][nx]==wall) continue;
if(~dp[ny][nx]) continue;
dp[ny][nx]=dp[y][x]+1;
q.emplace(ny,nx);
}
}
return dp;
}
int64_t power(int64_t x, int64_t n, int64_t mod) {
int64_t ret = 1;
while(n > 0) {
if(n & 1) (ret *= x) %= mod;
(x *= x) %= mod;
n >>= 1;
}
return ret;
}
vector<int> sieve_of_eratosthenes(int n) {
vector<int> primes(n);
for (int i = 2; i < n; ++i)
primes[i] = i;
for (int i = 2; i*i < n; ++i)
if (primes[i])
for (int j = i*i; j < n; j+=i)
primes[j] = 0;
return primes;
}
std::vector<ll> divisor(ll n)//nの約数を列挙
{
std::vector<ll> ret;
for(ll i=1 ; i*i<=n ; ++i)
{
if(n%i == 0)
{
ret.push_back(i);
if(i!=1 && i*i!=n)
{
ret.push_back(n/i);
}
}
}
return ret;
}
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
int R = INT_MAX;
int N;
cin >> N;
vector<int> a(N);
rep(i,N) cin >> a[i];
for(int i = -100; i <= 100; i++){
int s = 0;
for(int j = 0; j < N; j++) s += (A[j] - i) * (A[j] - i);
chmin(R,s);
}
cout << R << endl;
} | a.cc: In function 'int main()':
a.cc:199:50: error: 'A' was not declared in this scope
199 | for(int j = 0; j < N; j++) s += (A[j] - i) * (A[j] - i);
| ^
|
s209420819 | p04031 | C++ | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))
typedef long long ll;
const int INF = 1000000000;
const int MOD = 1000000007;
int main () {
int N; cin >> N;
vector<int> a(N);
rep(i, N) cin >> a[i];
ll ans = INF;
REP(i, -100, 100) {
int cst = 0;
rep(j, N) {
cst += (a[j] - i) * (a[j] - i);
}
ans = min(ans, cst);
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:27:26: error: no matching function for call to 'min(ll&, int&)'
27 | ans = min(ans, cst);
| ~~~^~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:27:26: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
27 | ans = min(ans, cst);
| ~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:27:26: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
27 | ans = min(ans, cst);
| ~~~^~~~~~~~~~
|
s398485816 | p04031 | C++ | #include<bits/stdc++.h>
using namespace std;
int main()
{
int n,minN=191,maxN=-1001;
cin>>n;
vector<int> a(n);
for(auto &i:a)
{
cin>>i;
minN = min(minN,i);
maxN = max(maxN,i);
}
if(minN==maxN)
{
cout<<"0\n";return 0;
}
int ans_val=1e9;
for(int i=minN;i<=maxN;i++)
{
temp = 0;
for(auto k:a) temp += ((k-i)*(k-i));
if(temp<ans_val)
{
ans_val = temp;
}
}
cout<<ans_val<<"\n";
return 0;
} | a.cc: In function 'int main()':
a.cc:22:5: error: 'temp' was not declared in this scope; did you mean 'tm'?
22 | temp = 0;
| ^~~~
| tm
|
s521617076 | p04031 | C++ | 4
-100 -100 -100 -100 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 4
| ^
|
s489713788 | p04031 | C++ | #include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define ll long long
#define endl \'n'
using namespace std;
const ll mod = (ll)10e9+7;
const int INF = 0x3f3f3f3f;
int a[101];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
for(int i=1; i<=n; i++)
{
cin >> a[i];
}
int ans=INT_MAX;
for(int i=-100; i<=100; i++)
{
int cur=0;
for(int j=1; j<=n; j++)
{
cur += (i-a[j])*(i-a[j]);
}
ans = min(ans, cur);
}
cout << ans;
}
| a.cc: In function 'int main()':
a.cc:23:13: error: 'INT_MAX' was not declared in this scope
23 | int ans=INT_MAX;
| ^~~~~~~
a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
5 | #include <vector>
+++ |+#include <climits>
6 |
|
s980723519 | p04031 | C++ | #include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define ll long long
#define endl \'n'
using namespace std;
const ll mod = (ll)10e9+7;
const int INF = 0x3f3f3f3f;
int a[101];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
for(int i=1; i<=n; i++)
{
cin >> a[i];
}
int ans=INT_MAX;
for(int i=-100; i<=100; i++)
{
int cur=0;
for(int j=1; j<=n; j++)
{
cur += (i-a[j])*(i-a[j]);
}
ans = min(ans, cur);
}
cout << ans;
}
| a.cc: In function 'int main()':
a.cc:23:13: error: 'INT_MAX' was not declared in this scope
23 | int ans=INT_MAX;
| ^~~~~~~
a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
5 | #include <vector>
+++ |+#include <climits>
6 |
|
s039747827 | p04031 | C++ | #include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define ll long long
#define endl \'n'
using namespace std;
const ll mod = (ll)10e9+7;
const int INF = 0x3f3f3f3f;
int a[101];
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
for(int i=1; i<=n; i++)
{
cin >> a[i];
}
int ans=MAX_INT;
for(int i=-100; i<=100; i++)
{
int cur=0;
for(int j=1; j<=n; j++)
{
cur += (i-a[j])*(i-a[j]);
}
ans = min(ans, cur);
}
cout << ans;
}
| a.cc: In function 'int main()':
a.cc:23:13: error: 'MAX_INT' was not declared in this scope
23 | int ans=MAX_INT;
| ^~~~~~~
|
s891447578 | p04031 | C++ | import java.util.*;
class Main {
public static void main(String[] args) {
Scanner seer = new Scanner(System.in);
int n = seer.nextInt();
int[] arr = new int[n];
for(int i = 0; i < n; i++){
arr[i] = seer.nextInt();
}
int mincost = Integer.MAX_VALUE;
for(int val = -100; val <= 100; val++){
int cost = 0;
for(int k: arr){
cost += (k - val)*(k - val);
}
mincost = Integer.min(mincost, cost);
}
System.out.println(mincost);
}
}
| a.cc:1:1: error: 'import' does not name a type
1 | import java.util.*;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:15: error: expected ':' before 'static'
4 | public static void main(String[] args) {
| ^~~~~~~
| :
a.cc:4:33: error: 'String' has not been declared
4 | public static void main(String[] args) {
| ^~~~~~
a.cc:4:42: error: expected ',' or '...' before 'args'
4 | public static void main(String[] args) {
| ^~~~
a.cc:22:2: error: expected ';' after class definition
22 | }
| ^
| ;
a.cc: In static member function 'static void Main::main(int*)':
a.cc:5:17: error: 'Scanner' was not declared in this scope
5 | Scanner seer = new Scanner(System.in);
| ^~~~~~~
a.cc:6:25: error: 'seer' was not declared in this scope
6 | int n = seer.nextInt();
| ^~~~
a.cc:7:20: error: structured binding declaration cannot have type 'int'
7 | int[] arr = new int[n];
| ^~
a.cc:7:20: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
a.cc:7:20: error: empty structured binding declaration
a.cc:7:23: error: expected initializer before 'arr'
7 | int[] arr = new int[n];
| ^~~
a.cc:9:25: error: 'arr' was not declared in this scope
9 | arr[i] = seer.nextInt();
| ^~~
a.cc:11:31: error: 'Integer' was not declared in this scope
11 | int mincost = Integer.MAX_VALUE;
| ^~~~~~~
a.cc:14:36: error: 'arr' was not declared in this scope
14 | for(int k: arr){
| ^~~
a.cc:19:17: error: 'System' was not declared in this scope
19 | System.out.println(mincost);
| ^~~~~~
|
s488243655 | p04031 | C++ | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner seer = new Scanner(System.in);
int n = seer.nextInt();
int[] arr = new int[n];
for(int i = 0; i < n; i++){
arr[i] = seer.nextInt();
}
int mincost = Integer.MAX_VALUE;
for(int val = -100; val <= 100; val++){
int cost = 0;
for(int k: arr){
cost += (k - val)*(k - val);
}
mincost = Integer.min(mincost, cost);
}
System.out.println(mincost);
}
}
| a.cc:1:1: error: 'import' does not name a type
1 | import java.util.*;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: expected unqualified-id before 'public'
2 | public class Main {
| ^~~~~~
|
s229643653 | p04031 | C++ | #include <bits/stdc++.h>
using namespace std;
int main()
{
cin >> n;
int a[n+1];
for (int i=1; i<=n; i++) cin >> a[i];
int res = 1e9;
for (int i=-100; i<=100; i++)
{
int sum = 0;
for (int j=1; j<=n; j++)
{
sum += (i-a[j])*(i-a[j]);
}
res = min(res, sum);
}
cout << res;
return 0;
} | a.cc: In function 'int main()':
a.cc:7:10: error: 'n' was not declared in this scope; did you mean 'yn'?
7 | cin >> n;
| ^
| yn
a.cc:9:35: error: 'a' was not declared in this scope
9 | for (int i=1; i<=n; i++) cin >> a[i];
| ^
a.cc:16:17: error: 'a' was not declared in this scope
16 | sum += (i-a[j])*(i-a[j]);
| ^
|
s846973569 | p04031 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int n, i, ave = 0, sum = 0;
cin >> n;
for(i=0; i<n; i++){
cin >> a[i];
ave += a[i];
}
ave = round((float)ave/n);
for(i=0; i<n; i++){
sum += (ave - a[i])*(ave -a[i]);
}
cout << sum;
return 0;
} | a.cc: In function 'int main()':
a.cc:8:16: error: 'a' was not declared in this scope
8 | cin >> a[i];
| ^
a.cc:13:23: error: 'a' was not declared in this scope
13 | sum += (ave - a[i])*(ave -a[i]);
| ^
|
s656322989 | p04031 | C++ | fukumotomitsuoki-no-MacBook-Pro:beginner_c littlelink$ cat 043.cpp
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int cal(vector<int>a,int n){
int sum=0;
for(int i=0;i<a.size();i++){
sum+=(a[i]-n)*(a[i]-n);
}
return sum;
}
int main(){
int n;
cin>>n;
vector<int> a(n);
int sum=0;
for(int i=0;i<n;i++){
cin>>a[i];
sum+=a[i];
}
int min=1000000,x;
for(int i=-100;i<101;i++){
x=cal(a,i);
min=(min<x)?min:x;
}
cout<<min<<endl;
return 0;
} | a.cc:1:1: error: 'fukumotomitsuoki' does not name a type
1 | fukumotomitsuoki-no-MacBook-Pro:beginner_c littlelink$ cat 043.cpp
| ^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/bits/postypes.h:68:11: error: 'ptrdiff_t' does not name a type
68 | typedef ptrdiff_t streamsize; // Signed integral type
| ^~~~~~~~~
/usr/include/c++/14/bits/postypes.h:41:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
40 | #include <cwchar> // For mbstate_t
+++ |+#include <cstddef>
41 |
In file included from /usr/include/c++/14/bits/exception_ptr.h:38,
from /usr/include/c++/14/exception:166,
from /usr/include/c++/14/ios:41:
/usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
In file included from /usr/include/wchar.h:35,
from /usr/include/c++/14/cwchar:44,
from /usr/include/c++/14/bits/postypes.h:40:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive]
132 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive]
134 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:140:29: error: 'std::size_t' has not been declared
140 | void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT
| ^~~
/usr/include/c++/14/new:142:31: error: 'std::size_t' has not been declared
142 | void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT
| ^~~
/usr/include/c++/14/new:145:26: error: declaration of 'operator new' as non-function
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/new:145:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:145:52: error: expected primary-expression before 'const'
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~
/usr/include/c++/14/new:147:26: error: declaration of 'operator new []' as non-function
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/new:147:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:147:54: error: expected primary-expression before 'const'
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~
/usr/include/c++/14/new:154:26: error: declaration of 'operator new' as non-function
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^~~~~~~~
/usr/include/c++/14/new:154:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:154:68: error: expected primary-expression before ')' token
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^
/usr/include/c++/14/new:155:73: error: attributes after parenthesized initializer ignored [-fpermissive]
155 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__));
| ^
/usr/include/c++/14/new:156:26: error: declaration of 'operator new' as non-function
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~~~
/usr/include/c++/14/new:156:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:156:68: error: expected primary-expression before ',' token
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^
/usr/include/c++/14/new:156:70: error: expected primary-expression before 'const'
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~
/usr/include/c++/14/new:162:26: error: declaration of 'operator new []' as non-function
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^~~~~~~~
/usr/include/c++/14/new:162:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:162:70: error: expected primary-expression before ')' token
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^
/usr/include/c++/14/new:163:73: error: attributes after parenthesized initializer ignored [-fpermissive]
163 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__));
| ^
/usr/include/c++/14/new:164:26: error: declaration of 'operator new []' as non-function
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~~~
/usr/include/c++/14/new:164:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:164:70: error: expected primary-expression before ',' token
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^
/usr/include/c++/14/new:164:72: error: expected primary-expression before 'const'
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~
/usr/include/c++/14/new:171:29: error: 'std::size_t' has not been declared
171 | void operator delete(void*, std::size_t, std::align_val_t)
| ^~~
/usr/include/c++/14/new:173:31: error: 'std::size_t' has not been declared
173 | void operator delete[](void*, std::size_t, std::align_val_t)
| ^~~
/usr/include/c++/14/new:179:33: error: declaration of 'operator new' as non-function
179 | _GLIBCXX_NODISCARD inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/new:179:51: error: 'size_t' |
s079093042 | p04031 | C | #include <stdio.h>
int mean(int a[], int n){
int sum;
for(int i=0;i<n;i++)
sum += a[i];
return (sum+1) / n;
}
int cost(int a[], int num, int mean){
int cost = 0;
for(int i=0;i<num;i++)
cost += (a[i] - mean) * (a[i] - mean);
return cost;
}
int main()
{
int N;
scanf("%d", &N);
int a[N];
for(int i=0;i<N;i++)
scanf("%d", a[i]);
int mean = mean(a, N);
int cost = cost(a, N, mean);
printf("%d", cost);
return 0;
} | main.c: In function 'main':
main.c:24:14: error: called object 'mean' is not a function or function pointer
24 | int mean = mean(a, N);
| ^~~~
main.c:24:7: note: declared here
24 | int mean = mean(a, N);
| ^~~~
main.c:25:14: error: called object 'cost' is not a function or function pointer
25 | int cost = cost(a, N, mean);
| ^~~~
main.c:25:7: note: declared here
25 | int cost = cost(a, N, mean);
| ^~~~
|
s693712488 | p04031 | C | #include <stdio.h>
int mean(int a[], int n){
int sum;
for(int i=0;i<n;i++)
sum += a[i];
return (sum+1) / n;
}
int cost(int a[], int num, int mean){
int cost = 0;
for(int i=0;i<num;i++)
cost += (a[i] - mean) * (a[i] - mean);
return cost;
}
int main()
{
int N;
scanf("%d", &N);
for(int i=0;i<N;i++)
scanf("%d", a[i]);
int mean = mean(a, N);
int cost = cost(a, N, mean);
printf("%d", cost);
return 0;
}
| main.c: In function 'main':
main.c:22:17: error: 'a' undeclared (first use in this function)
22 | scanf("%d", a[i]);
| ^
main.c:22:17: note: each undeclared identifier is reported only once for each function it appears in
main.c:23:14: error: called object 'mean' is not a function or function pointer
23 | int mean = mean(a, N);
| ^~~~
main.c:23:7: note: declared here
23 | int mean = mean(a, N);
| ^~~~
main.c:24:14: error: called object 'cost' is not a function or function pointer
24 | int cost = cost(a, N, mean);
| ^~~~
main.c:24:7: note: declared here
24 | int cost = cost(a, N, mean);
| ^~~~
|
s726544623 | p04031 | C++ | #include<iostream>
#include<vector>
using namespace std;
int main(){
int N,ans=0,minv=(1<<20);
cin>>N;
vector<int>a(N);
for(int i=0;i<N;++i)cin>>a[i];
for(int i=-100;i<=100;++i){
ans=0;
for(int j=0;j<N;++j){
ans+=pow((i-a[j]),2);
}minv=min(minv,ans);
}cout<<minv<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:13:22: error: 'pow' was not declared in this scope
13 | ans+=pow((i-a[j]),2);
| ^~~
|
s880817172 | p04031 | Java | public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int count = scanner.nextInt();
List<Integer> numbers = new ArrayList<>();
long sum = 0;
for (int ix = 0; ix < count; ix++) {
int value = scanner.nextInt();
sum += value;
numbers.add(value);
}
int cost = 0;
int average = (int)sum / numbers.size();
for (int num : numbers) {
int distance = Math.abs(num - average);
average += (distance * distance);
}
System.out.println(average);
}
} | Main.java:3: error: cannot find symbol
Scanner scanner = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:3: error: cannot find symbol
Scanner scanner = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:6: error: cannot find symbol
List<Integer> numbers = new ArrayList<>();
^
symbol: class List
location: class Main
Main.java:6: error: cannot find symbol
List<Integer> numbers = new ArrayList<>();
^
symbol: class ArrayList
location: class Main
4 errors
|
s396950668 | p04031 | Java | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int count = scanner.nextInt();
List<Integer> numbers = new ArrayList<>();
long sum = 0;
for (int ix = 0; ix < count; ix++) {
int value = scanner.nextInt();
sum += value;
numbers.add(value);
}
int cost = 0;
int average = sum / numbers.size();
for (int num : numbers) {
int distance = Math.abs(num - average);
average += (distance * distance);
}
System.out.println(average);
}
} | Main.java:17: error: incompatible types: possible lossy conversion from long to int
int average = sum / numbers.size();
^
1 error
|
s582250489 | p04031 | C++ | #include<iostream>
#include<vector>
using namespace std;
int main(){
int N;
cin >> N;
vector<int> a(N);
for(int i=0;i<N;i++){
cin >> a[i];
}
int answer;
vector<int> ans;
for(int j=-100;j<101;j++){
ans[j] = 0;
for(int i=0;i<N;i++){
ans[j]+=pow((a[i]-j),2);
}
}
answer = ans[-100];
for(int j=-99;j<101;j++){
if(ans[j-1]>ans[j]) answer= ans[j];
}
cout << answer << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:16:17: error: 'pow' was not declared in this scope
16 | ans[j]+=pow((a[i]-j),2);
| ^~~
|
s751372684 | p04031 | C++ | #include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;
#define sqr(x) ((x)*(x))
int main(){
int i, n;
long long find, find2;
int a[100];
cin >> n;
for(i=0; i<n; i++){
if((n <= -100) or (n >= 100)){
continue;
}
cin >> a[i];
if(a[i-1] == a[i]){
cnt++; //중복 값 검증
}
}
if((cnt == n) and (cnt != 0)){
cout << 0 << endl; // 중복 값 검증_2
return 0;
}
sort(a, (a + n));
for(int i=-101; i<101; i++){
find = 0;
for(int j = 0; j < n; j++){
find += sqr(i - a[j]);
}
find2 = min(find2, find);
}
cout << find2;
} | a.cc: In function 'int main()':
a.cc:20:17: error: 'cnt' was not declared in this scope; did you mean 'int'?
20 | cnt++; //중복 값 검증
| ^~~
| int
a.cc:23:13: error: 'cnt' was not declared in this scope; did you mean 'int'?
23 | if((cnt == n) and (cnt != 0)){
| ^~~
| int
|
s330231361 | p04031 | C++ | #include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;
#define sqr(x) ((x)*(x))
int main(){
int i, n;
long long find, find2;
int a[100];
cin >> n;
for(i=0; i<n; i++){
if((n <= -100) or (n >= 100)){
continue;
}
cin >> a[i];
if(a[i-1] == a[i]){
cnt++; //중복 값 검증
}
}
if((cnt == n) and (cnt != 0)){
cout << 0 << endl; // 중복 값 검증_2
exit();
}
sort(a, (a + n));
for(int i=-101; i<101; i++){
find = 0;
for(int j = 0; j < n; j++){
find += sqr(i - a[j]);
}
find2 = min(find2, find);
}
cout << find2;
} | a.cc: In function 'int main()':
a.cc:20:17: error: 'cnt' was not declared in this scope; did you mean 'int'?
20 | cnt++; //중복 값 검증
| ^~~
| int
a.cc:23:13: error: 'cnt' was not declared in this scope; did you mean 'int'?
23 | if((cnt == n) and (cnt != 0)){
| ^~~
| int
a.cc:25:17: error: too few arguments to function 'void exit(int)'
25 | exit();
| ~~~~^~
In file included from /usr/include/c++/14/cstdlib:79,
from /usr/include/c++/14/ext/string_conversions.h:43,
from /usr/include/c++/14/bits/basic_string.h:4154,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/stdlib.h:756:13: note: declared here
756 | extern void exit (int __status) __THROW __attribute__ ((__noreturn__));
| ^~~~
|
s875956085 | p04031 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
cout << setprecision(9);
int N;
cin >> N;
int a[100];
for(int i=0; i<N; i++) cin >> a[i];
LL ans = LL_MAX;
for(int i=-100; i<=100; i++){
LL tmp = 0;
for(int j=0; j<N; j++){
tmp += (i-a[j])*(i-a[j]);
}
ans = min(ans, tmp);
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:12:9: error: 'LL' was not declared in this scope
12 | LL ans = LL_MAX;
| ^~
a.cc:14:19: error: expected ';' before 'tmp'
14 | LL tmp = 0;
| ^~~~
| ;
a.cc:16:25: error: 'tmp' was not declared in this scope; did you mean 'tm'?
16 | tmp += (i-a[j])*(i-a[j]);
| ^~~
| tm
a.cc:18:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
18 | ans = min(ans, tmp);
| ^~~
| abs
a.cc:18:32: error: 'tmp' was not declared in this scope; did you mean 'tm'?
18 | ans = min(ans, tmp);
| ^~~
| tm
a.cc:20:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
20 | cout << ans << endl;
| ^~~
| abs
|
s053014748 | p04031 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 10000
#define MAP 100
#define Pair pair<int,int>
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
int main(){
int n; cin >> n;
for(int i = 0; i < n; i++){
cin >> a[i];
}
int ans = MM;
for(int i = -100; i <= 100; i++){
int sum = 0;
for(int j = 0; j < n; j++){
sum += (i-a[j])*(i-a[j]);
}
ans = min(ans, sum);
}
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:17:16: error: 'a' was not declared in this scope
17 | cin >> a[i];
| ^
a.cc:23:23: error: 'a' was not declared in this scope
23 | sum += (i-a[j])*(i-a[j]);
| ^
|
s618430336 | p04031 | C | #include <stdio.h>
#include <math.h>
int main(void){
int n,i,j,min=4000000,res,a[100];
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
for(j=-100;j<=100;j++){
res = 0
for(i=0;i<n;i++){
res += (a[i] - j) * (a[i] - j);
}
if(res < min)min = res;
}
printf("%d\n",min);
} | main.c: In function 'main':
main.c:11:24: error: expected ';' before 'for'
11 | res = 0
| ^
| ;
12 | for(i=0;i<n;i++){
| ~~~
|
s406597877 | p04031 | C | #include <stdio.h>
#include <math.h>
int main(void){
int n,i,j,min=4000000,res;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%lf",&a[i]);
}
for(j=-100;j<=100;j++){
res = 0
for(i=0;i<n;i++){
res += (a[i] - j) * (a[i] - j);
}
if(res < min)min = res;
}
printf("%d\n",min);
} | main.c: In function 'main':
main.c:8:30: error: 'a' undeclared (first use in this function)
8 | scanf("%lf",&a[i]);
| ^
main.c:8:30: note: each undeclared identifier is reported only once for each function it appears in
main.c:11:24: error: expected ';' before 'for'
11 | res = 0
| ^
| ;
12 | for(i=0;i<n;i++){
| ~~~
|
s257014411 | p04031 | C++ | v]#include <bits/stdc++.h>
using namespace std;
int main(void){
int N;
cin >> N;
vector<int> A(N);
for(int i=0; i<N; i++) cin >> A[i];
sort(A.begin(), A.end());
int cost=pow(10,9);
for(int x=A[0]; x<A[N-1]+1; x++){
int tmp=0;
for(int i=0; i<N; i++) tmp += (A[i]-x)*(A[i]-x);
cost=min(tmp,cost);
}
cout << cost << endl;
return 0;
} | a.cc:1:3: error: stray '#' in program
1 | v]#include <bits/stdc++.h>
| ^
a.cc:1:1: error: 'v' does not name a type
1 | v]#include <bits/stdc++.h>
| ^
a.cc: In function 'int main()':
a.cc:6:5: error: 'cin' was not declared in this scope
6 | cin >> N;
| ^~~
a.cc:7:5: error: 'vector' was not declared in this scope
7 | vector<int> A(N);
| ^~~~~~
a.cc:7:12: error: expected primary-expression before 'int'
7 | vector<int> A(N);
| ^~~
a.cc:8:35: error: 'A' was not declared in this scope
8 | for(int i=0; i<N; i++) cin >> A[i];
| ^
a.cc:10:10: error: 'A' was not declared in this scope
10 | sort(A.begin(), A.end());
| ^
a.cc:10:5: error: 'sort' was not declared in this scope; did you mean 'short'?
10 | sort(A.begin(), A.end());
| ^~~~
| short
a.cc:11:14: error: 'pow' was not declared in this scope
11 | int cost=pow(10,9);
| ^~~
a.cc:16:14: error: 'min' was not declared in this scope; did you mean 'main'?
16 | cost=min(tmp,cost);
| ^~~
| main
a.cc:20:5: error: 'cout' was not declared in this scope; did you mean 'cost'?
20 | cout << cost << endl;
| ^~~~
| cost
a.cc:20:21: error: 'endl' was not declared in this scope
20 | cout << cost << endl;
| ^~~~
|
s853608685 | p04031 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> a(n);
int sum = 0;
for (int i = 0; i < n; i++) {
cin >> a[i];
sum++;
}
int x = sum / n;
int ans = 0;
for (int i = 0; i < n; i++) {
ans += abs(a[i] - sum);
}
cout < ans << endl;
} | a.cc: In function 'int main()':
a.cc:18:14: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
18 | cout < ans << endl;
| ~~~~^~~~~~~
|
s117972416 | p04031 | C++ | // Created by sz
#include <bits/stdc++.h>
using namespace std;
int main(){
#ifdef LOCAL
freopen("./input.txt", "r", stdin);
#endif
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n;
vector<int> a(n);
int sum = 0;
for(int i = 0; i< n;i++){cin>>a[i];sum+= a[i];}
int avg = sum/n;
int less_avg = avg-1, more_avg = avg + 1;
int sum_avg = 0, sum_le = 0, sum_mo = 0;
for(int i = 0; i < n; i++){
sum_avg += (a[i] - avg)*(a[i] - avg);
sum_le +=(a[i] - less_avgavg)*(a[i] - less_avg);
sum_mo +=(a[i] - more_avg)*(a[i] - more_avg);
}
cout<<min(min(sum_avg, sum_mo), sum_le)<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:24:26: error: 'less_avgavg' was not declared in this scope; did you mean 'less_avg'?
24 | sum_le +=(a[i] - less_avgavg)*(a[i] - less_avg);
| ^~~~~~~~~~~
| less_avg
|
s650632579 | p04031 | C++ | # include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int main()
{
optimize_cin();
int N; cin >> N;
vector<int> a;
a.resize(N);
rep (i, N) { cin >> a[i]; }
sort(ALL(a));
int d = abs(a[a.size() - 1] - a[0]);
bool can = false;
if (d % 2) // 奇数
{
int target = d / 2 + a[0];
rep (i, N)
{
if (target == a[i])
{
can = true;
break;
}
}
if (can)
{
int cost = 0;
rep (i, N)
{
cost += (a[i] - target)*(a[i] - target);
}
cout << cost << "\n";
}
else
{
target += (a[i] < 0 && a[a.size()-1] < 0) ? -1 : 1;
int cost = 0;
rep (i, N)
{
cost += (a[i] - target)*(a[i] - target);
}
cout << cost << "\n";
}
}
else
{
int target = d / 2 + a[0];
int cost = 0;
rep (i, N)
{
cost += (a[i] - target)*(a[i] - target);
}
cout << cost << "\n";
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:50:26: error: 'i' was not declared in this scope
50 | target += (a[i] < 0 && a[a.size()-1] < 0) ? -1 : 1;
| ^
|
s933884949 | p04031 | C++ | #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
int N; cin >> N;
vector<int> vc;
for (int i = 0; i < N; i++) {
int a; cin >> a;
vc.push_back(a);
}
int Min = 100000000;
for (int j = -100; j <= 100; j++) {
int cost = 0;
for (int i = 0; i < N; i++) {
int dif = vc[i] - j;
cost += pow(dif, 2);
}
Min = min(Min, cost);
}
cout << Min << endl;
//system("pause");
return 0;
} | a.cc: In function 'int main()':
a.cc:18:33: error: 'pow' was not declared in this scope
18 | cost += pow(dif, 2);
| ^~~
|
s227892495 | p04031 | C++ | #include<bits/stdc++.h>
#include<string>
using namespace std;
int n;
int main(){
cin >> n;
int a;
for(int i = 0; i < n; i++){
cin >> a[i];
int cost = 0;
for(int j = i+1; j < n; j++){
if(a[i] == a[j]) {
a[j] = a[i];
cost += pow(a[j] - a[i], 2);
}
}
}
cout << cost << endl;
} | a.cc: In function 'int main()':
a.cc:9:13: error: invalid types 'int[int]' for array subscript
9 | cin >> a[i];
| ^
a.cc:12:11: error: invalid types 'int[int]' for array subscript
12 | if(a[i] == a[j]) {
| ^
a.cc:12:19: error: invalid types 'int[int]' for array subscript
12 | if(a[i] == a[j]) {
| ^
a.cc:13:10: error: invalid types 'int[int]' for array subscript
13 | a[j] = a[i];
| ^
a.cc:13:17: error: invalid types 'int[int]' for array subscript
13 | a[j] = a[i];
| ^
a.cc:14:22: error: invalid types 'int[int]' for array subscript
14 | cost += pow(a[j] - a[i], 2);
| ^
a.cc:14:29: error: invalid types 'int[int]' for array subscript
14 | cost += pow(a[j] - a[i], 2);
| ^
a.cc:19:11: error: 'cost' was not declared in this scope; did you mean 'cosl'?
19 | cout << cost << endl;
| ^~~~
| cosl
|
s152358514 | p04031 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
int m=1000000;
vector<int> a(102),s(202);
for(int i-1;i<=N;i++){cin >> a[i];}
for(int i=-100;i<=100;i++){s[i]=0;}
for(int i=-100;i<=100;i++){
for(int j=1;j<=N;j++){
s[i]+=(i-a[j])*(i-a[j]);
}
if(m>s[i]){m=s[i];}
}
cout << m << endl;
} | a.cc: In function 'int main()':
a.cc:9:12: error: expected ';' before '-' token
9 | for(int i-1;i<=N;i++){cin >> a[i];}
| ^
| ;
a.cc:9:19: error: expected ')' before ';' token
9 | for(int i-1;i<=N;i++){cin >> a[i];}
| ~ ^
| )
a.cc:9:20: error: 'i' was not declared in this scope
9 | for(int i-1;i<=N;i++){cin >> a[i];}
| ^
|
s224423548 | p04031 | C++ | #include<iostream>
using namespace std;
int main(void)
{
int N;
cin >> N;
int cost[N][201];
int now;
for(int i=1;i<=N;i++)
{
cin >> now;
for(int j=-100;j<=100;j++)
{
cost[i-1][j+101-1]=(now-j)*(now-j);
}
}
int total_cost[201];
for(int i=1;i<=201;i++)
{
total_cost[i-1]=0;
for(int j=1;j<=N;j++)
{
total_cost[i-1]+=cost[j-1][i-1];
}
}
sort(total_cost,total_cost+201);
cout << total_cost[0] << endl;
}
| a.cc: In function 'int main()':
a.cc:29:9: error: 'sort' was not declared in this scope; did you mean 'short'?
29 | sort(total_cost,total_cost+201);
| ^~~~
| short
|
s278217600 | p04031 | C++ | #include<bits/stdc++.h>
using namespace std;
int main() {
int N;
cin>>N;
int a[N];
for(int i=0;i<N;i++){
a[i]=0;
}
int sum=0;
for(int i=0;i<N;i++){
cin>>a[i];
sum+=a[i];
}
float k=(float)sum/(float)N;
if(k>sum/N+0.5){
int ave=sum/N+1;
}else{
int ave=sum/N;
}
int kei=0;
for(int i=0;i,N;i++){
kei+=(a[i]-ave)*(a[i]-ave);
}
cout<<kei<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:24:20: error: 'ave' was not declared in this scope
24 | kei+=(a[i]-ave)*(a[i]-ave);
| ^~~
|
s574599723 | p04031 | C++ | #include<bits/stdc++.h>
using namespace std;
int a[105];
int f(int k)
{
int ans=0;
for(int i=0;i<n;i++)
ans+=(k-a[i])*(k-a[i]);
return ans;
}
int main()
{
int n,sum=0;
cin>>n;
for(int i=0;i<n;i++) cin>>a[i],sum+=a[i];
int k;
if(sum>0) k=ceil(sum*1.0/n);
else k=sum/n;
int ans=1e9;
ans=min(ans,f(k));
ans=min(ans,f(k-1));
ans=min(ans,f(k+1));
printf("%d\n",ans);
}
| a.cc: In function 'int f(int)':
a.cc:7:19: error: 'n' was not declared in this scope
7 | for(int i=0;i<n;i++)
| ^
|
s880087435 | p04031 | C++ | #include <bits/stdc++.h>
using namespace std;
static const int INF = (1<<29)
int N;
int a[109];
int main(){
cin >> N;
for(int i=0;i<N;i++){
cin >> a[i];
}
int sum=0;
for(int i=0;i<N;i++) sum += a[i];
int ans = INF;
for(int i=(-100);i<=100;i++){
int cost = 0;
for(int j=0;j<N;j++){
cost += (a[j]-i) * (a[j]-i);
}
ans = min(ans,cost);
}
cout << ans << endl;
return 0;
}
| a.cc:5:1: error: expected ',' or ';' before 'int'
5 | int N;
| ^~~
a.cc: In function 'int main()':
a.cc:9:10: error: 'N' was not declared in this scope
9 | cin >> N;
| ^
|
s699262542 | p04031 | C++ | #include <bits/stdc++.h>
using namespace std;
inline int sqr(int x) return x*x;
int main()
{
int n,a[101];
cin>>n;
int ans=0;
for(int i=1;i<=n;i++)
{
cin>>a[i];
ans+=sqr(a[i]-0);
}
for(x=-100;x<=100;x++)
{
int tmp=0;
for(int i=1;i<=n;i++)
{
tmp+=sqr(a[i]-x);
}
ans=min(ans,tmp);
}
cout<<ans;
}
| a.cc: In function 'int sqr(int)':
a.cc:3:23: error: named return values are no longer supported
3 | inline int sqr(int x) return x*x;
| ^~~~~~
a.cc:24:1: warning: no return statement in function returning non-void [-Wreturn-type]
24 | }
| ^
|
s753022515 | p04031 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
long long N;
cin >> N;
long long sum{}, result{}, input;
vector<long long> a(N);
for(auto& item: a) {
cin >> input;
item = input;
sum += input;
}
if (sum % N) {
auto y = sum / N;
size_t _1{};
for(auto&& x: a) {
_1 += pow(x - y, 2);
}
y = sum / N + 1;
size_t _2{};
for(auto&& x: a) {
_2 += pow(x - y, 2);
}
result = std::min(_1, _2);
}
else {
for(auto&& x: a) {
result += pow(x - y, 2);
}
}
cout << result << endl;
} | a.cc: In function 'int main()':
a.cc:28:31: error: 'y' was not declared in this scope
28 | result += pow(x - y, 2);
| ^
|
s227973553 | p04031 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
size_t N;
cin >> N;
size_t sum{}, result{};
vector<size_t> a(N);
for(size_t i{}, tmp; i < N; ++i) {
cin >> tmp;
a[i] = tmp;
sum += tmp;
}
auto y = sum / N;
for(size_t x: a) {
result += pow(x - y);
}
cout << result << endl;
} | a.cc: In function 'int main()':
a.cc:15:22: error: no matching function for call to 'pow(size_t)'
15 | result += pow(x - y);
| ~~~^~~~~~~
In file included from /usr/include/c++/14/valarray:605,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166,
from a.cc:1:
/usr/include/c++/14/bits/valarray_after.h:549:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::_Pow, std::_Constant, std::_ValArray, _Tp, _Tp>, _Tp> std::pow(const typename valarray<_Tp>::value_type&, const valarray<_Tp>&)'
549 | _DEFINE_EXPR_BINARY_FUNCTION(pow, struct std::_Pow)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:549:1: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/valarray_after.h:549:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::_Pow, std::_ValArray, std::_Constant, _Tp, _Tp>, _Tp> std::pow(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)'
549 | _DEFINE_EXPR_BINARY_FUNCTION(pow, struct std::_Pow)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:549:1: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/valarray_after.h:549:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::_Pow, std::_ValArray, std::_ValArray, _Tp, _Tp>, _Tp> std::pow(const valarray<_Tp>&, const valarray<_Tp>&)'
549 | _DEFINE_EXPR_BINARY_FUNCTION(pow, struct std::_Pow)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:549:1: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/valarray_after.h:549:1: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::_Pow, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename _Dom::value_type> std::pow(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)'
549 | _DEFINE_EXPR_BINARY_FUNCTION(pow, struct std::_Pow)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:549:1: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/valarray_after.h:549:1: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::_Pow, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename _Dom::value_type> std::pow(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)'
549 | _DEFINE_EXPR_BINARY_FUNCTION(pow, struct std::_Pow)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:549:1: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/valarray_after.h:549:1: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::_Pow, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename _Dom::value_type> std::pow(const valarray<typename _Dom::valarray>&, const _Expr<_Dom1, typename _Dom1::value_type>&)'
549 | _DEFINE_EXPR_BINARY_FUNCTION(pow, struct std::_Pow)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:549:1: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/valarray_after.h:549:1: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::_Pow, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename _Dom::value_type> std::pow(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)'
549 | _DEFINE_EXPR_BINARY_FUNCTION(pow, struct std::_Pow)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:549:1: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/valarray_after.h:549:1: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::_Pow, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename _Dom1::value_type> std::pow(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)'
549 | _DEFINE_EXPR_BINARY_FUNCTION(pow, struct std::_Pow)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:549:1: note: candidate expects 2 arguments, 1 provided
In file included from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/complex:2482:5: note: candidate: 'template<class _Tp, class _Up> std::complex<typename __gnu_cxx::__promote<decltype (((typename __gnu_cxx::__promote<_Tp, std::__is_integer<_Tp>::__value>::__type)(0) + (typename __gnu_cxx::__promote<_Up, std::__is_integer<_Up>::__value>::__type)(0)))>::__type> std::pow(const complex<_Tp>&, const complex<_Up>&)'
2482 | pow(const std::complex<_Tp>& __x, const std::complex<_Up>& __y)
| ^~~
/usr/include/c++/14/complex:2482:5: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/complex:2474:5: note: candidate: 'template<class _Tp, class _Up> std::complex<typename __gnu_cxx::__promote<decltype (((typename __gnu_cxx::__promote<_Tp, std::__is_integer<_Tp>::__value>::__type)(0) + (typename __gnu_cxx::__promote<_Up, std::__is_integer<_Up>::__value>::__type)(0)))>::__type> std::pow(const _Tp&, const complex<_Up>&)'
2474 | pow(const _Tp& __x, const std::complex<_Up>& __y)
| ^~~
/usr/include/c++/14/complex:2474:5: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/complex:2466:5: note: candidate: 'template<class _Tp, class _Up> std::complex<typename __gnu_cxx::__promote<decltype (((typename __gnu_cxx::__promote<_Tp, std::__is_integer<_Tp>::__value>::__type)(0) + (typename __gnu_cxx::__promote<_Up, std::__is_integer<_Up>::__value>::__type)(0)))>::__type> std::pow(const complex<_Tp>&, const _Up&)'
2466 | pow(const std::complex<_Tp>& __x, const _Up& __y)
| ^~~
/usr/include/c++/14/complex:2466:5: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/complex:1339:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::pow(const _Tp&, const complex<_Tp>&)'
1339 | pow(const _Tp& __x, const complex<_Tp>& __y)
| ^~~
/usr/include/c++/14/complex:1339:5: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/complex:1328:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::pow(const complex<_Tp>&, const complex<_Tp>&)'
1328 | pow(const complex<_Tp>& __x, const complex<_Tp>& __y)
| ^~~
/usr/include/c++/14/complex:1328:5: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/complex:1294:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::pow(const complex<_Tp>&, const _Tp&)'
1294 | pow(const complex<_Tp>& __x, const _Tp& __y)
| ^~~
/usr/include/c++/14/complex:1294:5: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/complex:1285:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::pow(const complex<_Tp>&, int)'
1285 | pow(const complex<_Tp>& __z, int __n)
| ^~~
/usr/include/c++/14/complex:1285:5: note: candidate expects 2 arguments, 1 provided
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:114:
/usr/include/c++/14/cmath:1074:5: note: candidate: 'template<class _Tp, class _Up> constexpr typename __gnu_cxx::__promote_2<_Tp, _Up>::__type std::pow(_Tp, _Up)'
1074 | pow(_Tp __x, _Up __y)
| ^~~
/usr/include/c++/14/cmath:1074:5: note: candidate expects 2 arguments, 1 provided
In file included from /usr/include/features.h:523,
from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683,
from /usr/include/c++/14/cassert:43,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:173:1: note: candidate: 'double pow(double, double)'
173 | __MATHCALL_VEC (pow,, (_Mdouble_ __x, _Mdouble_ __y));
| ^~~~~~~~~~~~~~
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:173:1: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/cmath:380:3: note: candidate: 'constexpr long double std::pow(long double, long double)'
380 | pow(long double __x, long double __y)
| ^~~
/usr/include/c++/14/cmath:380:3: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/cmath:376:3: note: candidate: 'constexpr float std::pow(float, float)'
376 | pow(float __x, float __y)
| ^~~
/usr/include/c++/14/cmath:376:3: note: candidate expects 2 arguments, 1 provided
|
s354192492 | p04031 | C++ | #include<bits/stdc++.h>
#define lp3(i,a,b) for(int i=a;i<b;i++)
#define lp2(i,n) for(int i=0;i<n;i++)
#define ll long long
#define W 1000000007
using namespace std;
int main(){
int n,a,sum1=0,sum2=0;
cin>>n;
lp2(i,n){
cin>>a;
sum1+=a;
sum2+=pow(a,2);
}
sum1= pow(sum1,2);
double ans = sum2 - sum1/n;
int num=(ans*10)%10;
if(num!=0)ans++;
int ans1 = ans;
cout<<ans<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:18:25: error: invalid operands of types 'double' and 'int' to binary 'operator%'
18 | int num=(ans*10)%10;
| ~~~~~~~~^~~
| | |
| | int
| double
|
s633107579 | p04031 | C++ | #include <iostream>
#include <math.h>
#include <vector>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>
typedef long long ll;
using namespace std;
int main(){
int N;
cin>>N;
int a[N];
for(int i=0;i<N;i++)cin>>a[i];
int ans=INT_MAX;
for(int i=-100;i<=100;i++){
int cost=0;
for(int j=0;j<N;j++)cost+=(a[j]-i)*(a[j]-i);
if(cost<ans)ans=cost;
}
cout<<ans<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:18:11: error: 'INT_MAX' was not declared in this scope
18 | int ans=INT_MAX;
| ^~~~~~~
a.cc:8:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
7 | #include <string.h>
+++ |+#include <climits>
8 |
|
s114903731 | p04031 | C++ | #include<iostream>
#include<vector>
using namespace std;
int main(){
int s=0,n;
vector<int> a;
cin>>n;
for(int i=0;i<n;i++){
int temp;
cin>>temp;
a.push_back(temp);
s+=temp;
}
s/=n;
int res=0;
for(int i=s;i<=s+1;i++){
for(int j=0;j<n;j++){
res+=(i-a[j])*(i-a[j]);
}if(i==s){
int k=res
}else if(k<res){
cout<<k;
}else{
cout<<res;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:21:17: error: expected ',' or ';' before '}' token
21 | }else if(k<res){
| ^
a.cc:21:26: error: 'k' was not declared in this scope
21 | }else if(k<res){
| ^
|
s809255553 | p04031 | C++ | #include <iostream>
int main()
{
int total = 0;
std::cin >> N;
for (int i = 0; i < N; i++) {
std::cin >> a[i];
total += a[i];
}
int ave;
if (total%N == 0)
ave = total / N;
else
if (total > 0)
ave = total / N + 1;
else
ave = total / N - 1;
int ans = 0;
for (int i = 0; i < N; i++)
ans += (ave - a[i])*(ave - a[i]);
std::cout << ans << '\n';
return 0;
} | a.cc: In function 'int main()':
a.cc:7:21: error: 'N' was not declared in this scope
7 | std::cin >> N;
| ^
a.cc:9:29: error: 'a' was not declared in this scope
9 | std::cin >> a[i];
| ^
a.cc:25:31: error: 'a' was not declared in this scope
25 | ans += (ave - a[i])*(ave - a[i]);
| ^
|
s709455055 | p04031 | C++ | #include <iostream>
#include <cmath>
#include <vector>
using std::cin;
using std::cout;
using std::endl;
using std::pow;
using std::vector;
int main() {
int n, min, max, ave, cost;
vector<int> a;
cin >> n;
for (int i = 0; i < n; i++) {
int num;
cin >> num;
a.push_back(num);
}
sort(a.begin(), a.end() );
max = a.back();
min = a.front();
ave = ceil((double(max) + double(min)) / 2.0);
// 書き換え
for (int x : a) {
cost += pow(ave - x, 2);
}
cout << cost << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:23:3: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
23 | sort(a.begin(), a.end() );
| ^~~~
| sqrt
|
s451440022 | p04031 | C++ | #include <iostream>
#include <cmath>
#include <vector>
using std::cin;
using std::cout;
using std::endl;
using std::pow;
using std::vector;
int main() {
int n, min, max, ave, cost;
vector<int> a;
cin >> n;
for (int i = 0; i < n; i++) {
int num;
cin >> num;
a.push_back(num);
}
sort(a.begin(), a.end() );
max = a.back();
min = a.front();
ave = (max + min) / 2;
// 書き換え
for (int x : a) {
cost += pow(ave - x, 2);
}
cout << cost << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:23:3: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
23 | sort(a.begin(), a.end() );
| ^~~~
| sqrt
|
s905303096 | p04031 | C++ | #include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
int n,cost=0;
float m=0.0;
scanf("%d",&n);
int a[n];
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
m+=a[i];
}
m/=n;
m=ceil(m);
for(int i=0;i<n;i++)
cost+=((a[i]-m)*(a[i]-m));
printf("%d",cost);
return 0;
}
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
int n,cost=0;
float m=0.0;
scanf("%d",&n);
int a[n];
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
m+=a[i];
}
m/=n;
int p;
p=m;
if((m-p)>0.5)p++;
for(int i=0;i<n;i++)
cost+=((a[i]-p)*(a[i]-p));
printf("%d",cost);
return 0;
}
| a.cc:31:5: error: redefinition of 'int main()'
31 | int main()
| ^~~~
a.cc:5:9: note: 'int main()' previously defined here
5 | int main()
| ^~~~
|
s887420784 | p04031 | C++ | #include <iostream>
#include <string>
#include <cmath>
int main(){
int a[100];
int n,ans=INT_MAX;
std::cin>>n;
for(int i=0;i<n;++i){
std::cin>>a[i];
}
for(int i=-100;i<100;++i){
int tmp=0;
for(int j=0;j<n;++j){
tmp+=std::pow(i-a[j],2);
}
if(ans>tmp){
ans=tmp;
}
}
std::cout<<ans;
} | a.cc: In function 'int main()':
a.cc:6:14: error: 'INT_MAX' was not declared in this scope
6 | int n,ans=INT_MAX;
| ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
3 | #include <cmath>
+++ |+#include <climits>
4 | int main(){
|
s789412002 | p04031 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
int N;
cin >> N;
vector<int> A;
int num;
for(int i=0; i<N; i++){
cin >> num;
A.push_back(num);
}
std::sort(A.begin(), A.end() );
int min_cost;
int cost, target_num; // temp cost, temp target_num
for(int i = A.front(); i <= A.back(); i++){
cost = 0;
target_num = i;
for(vector<int>::iterator it = A.begin(); it != A.end(); it++){
cost += (*it - target_num) * (*it - target_num);
}
if ( i == A.front() || min_cost > cost){
min_cost = cost;
}
}
cout << min_cost << endl;
return 0;
} | a.cc:22:26: error: extended character is not valid in an identifier
22 | int cost, target_num; // temp cost, temp target_num
| ^
a.cc: In function 'int main()':
a.cc:22:26: error: '\U00003000' was not declared in this scope
22 | int cost, target_num; // temp cost, temp target_num
| ^~
a.cc:23:28: error: 'i' was not declared in this scope
23 | for(int i = A.front(); i <= A.back(); i++){
| ^
|
s538787725 | p04031 | C++ | #include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int N;
cin >> N;
int *ary = new int[N];
for (int i = 0; i < N; i++)
{
cin >> ary[i];
}
int sum = 0;
for (int i = 0; i < N; i++)
{
sum += ary[i];
}
int x = (int)round(sum / (0. + N));
//cout << x << endl;
int cost = 0;
for (int i = 0; i < N; i++)
{
int a = ary[i] - x;
cost += a * a;
}
cout << cost << endl;
delete[] ary;
return 0;
} | a.cc: In function 'int main()':
a.cc:22:18: error: 'round' was not declared in this scope
22 | int x = (int)round(sum / (0. + N));
| ^~~~~
|
s326076687 | p04031 | C++ | #include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int N;
cin >> N;
int *ary = new int[N];
for (int i = 0; i < N; i++)
{
cin >> ary[i];
}
int sum = 0;
for (int i = 0; i < N; i++)
{
sum += ary[i];
}
int x = (int)round(sum / (0. + N));
//cout << x << endl;
int cost = 0;
for (int i = 0; i < N; i++)
{
int a = ary[i] - x;
cost += a * a;
}
cout << cost << endl;
delete[] ary;
return 0;
} | a.cc: In function 'int main()':
a.cc:22:18: error: 'round' was not declared in this scope
22 | int x = (int)round(sum / (0. + N));
| ^~~~~
|
s187929005 | p04031 | C++ | #include<iostream>
#include<vector>
using namespace std;
int main(){
int N;
cin>>N;
int a[N];
vector<int> cost;
for(int i=0;i<N;i++){cin>>a[i];}
for(int i=-100;i<=100;i++){
int temp=0;
for(int j=0;j<N;j++)temp+=((a[j]-i)*(a[j]-i));
cost.push_back(temp);
}
int ans=*min_element(cost.begin(),cost.end());
cout<<ans<<endl;
} | a.cc: In function 'int main()':
a.cc:15:12: error: 'min_element' was not declared in this scope
15 | int ans=*min_element(cost.begin(),cost.end());
| ^~~~~~~~~~~
|
s437847015 | p04031 | C++ | #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
int N;
cin>>N;
int a[N];
vector<int> cost;
for(int i=0;i<N;i++)cin>>a[N];
for(int i=-100;i<=100;i++){
int temp=0;
for(int j=0;j<N;j++)temp+=((a[j]-i)*(a[j]-i));
cost.push_back(temp);
}
int ans=cost[min_element(cost.begin(),cost.end())];
cout<<ans<<endl;
} | a.cc: In function 'int main()':
a.cc:16:15: error: no match for 'operator[]' (operand types are 'std::vector<int>' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >')
16 | int ans=cost[min_element(cost.begin(),cost.end())];
| ^
In file included from /usr/include/c++/14/vector:66,
from a.cc:3:
/usr/include/c++/14/bits/stl_vector.h:1128:7: note: candidate: 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](size_type) [with _Tp = int; _Alloc = std::allocator<int>; reference = int&; size_type = long unsigned int]'
1128 | operator[](size_type __n) _GLIBCXX_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1128:28: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
1128 | operator[](size_type __n) _GLIBCXX_NOEXCEPT
| ~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1147:7: note: candidate: 'std::vector<_Tp, _Alloc>::const_reference std::vector<_Tp, _Alloc>::operator[](size_type) const [with _Tp = int; _Alloc = std::allocator<int>; const_reference = const int&; size_type = long unsigned int]'
1147 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1147:28: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'std::vector<int>::size_type' {aka 'long unsigned int'}
1147 | operator[](size_type __n) const _GLIBCXX_NOEXCEPT
| ~~~~~~~~~~^~~
|
s497393119 | p04031 | C++ | #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
int N;
cin>>N;
int a[N];
vector<int> cost;
for(int i=0;i<N;i++)cin>>a[N];
for(int i=-100;i<=100;i++){
int temp=0;
for(int j=0;j<N;j++)temp+=((a[j]-i)*(a[j]-i));
cost.push_back(temp);
}
int ans=min_element(cost.begin(),cost.end());
cout<<ans<<endl;
} | a.cc: In function 'int main()':
a.cc:16:22: error: cannot convert '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'int' in initialization
16 | int ans=min_element(cost.begin(),cost.end());
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
| |
| __gnu_cxx::__normal_iterator<int*, std::vector<int> >
|
s152519699 | p04031 | C++ | #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
int N;
cin>>N;
int a[N];
vector<int> cost;
for(int i=0;i<N;i++)cin>>a[N];
for(int i=-100;i<=100;i++){
int temp=0;
for(int j=0;j<N;j++)temp+=((a[j]-i)*(a[j]-i));
cost.push_back(temp);
}
int ans=min_element(cost.begin(),cost.end())
cout<<ans<<endl;
} | a.cc: In function 'int main()':
a.cc:16:22: error: cannot convert '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'int' in initialization
16 | int ans=min_element(cost.begin(),cost.end())
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
| |
| __gnu_cxx::__normal_iterator<int*, std::vector<int> >
|
s553053390 | p04031 | C++ | #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
int N;
cin>>N;
int a[N];
vector<int> cost;
for(int i=0;i<N;i++)cin>>a[N];
for(int i=-100;i<=100;i++){
int temp=0;
for(int j=0;j<N;j++)temp+=((a[j]-i)*(a[j]-i));
cost.push_back(temp);
}
cout<<min_element(cost.begin(),cost.end())<<endl;
} | a.cc: In function 'int main()':
a.cc:16:7: error: no match for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >')
16 | cout<<min_element(cost.begin(),cost.end())<<endl;
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| | __gnu_cxx::__normal_iterator<int*, std::vector<int> >
| std::ostream {aka std::basic_ostream<char>}
In file included from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'}
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]'
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ^~~~~~~~
/usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'std::ios_base& (*)(std::ios_base&)'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
174 | operator<<(long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'long int'
174 | operator<<(long __n)
| ~~~~~^~~
/usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
178 | operator<<(unsigned long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'long unsigned int'
178 | operator<<(unsigned long __n)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
182 | operator<<(bool __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'bool'
182 | operator<<(bool __n)
| ~~~~~^~~
In file included from /usr/include/c++/14/ostream:1022:
/usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]'
96 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'short int'
97 | operator<<(short __n)
| ~~~~~~^~~
/usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
189 | operator<<(unsigned short __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'short unsigned int'
189 | operator<<(unsigned short __n)
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]'
110 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'int'
111 | operator<<(int __n)
| ~~~~^~~
/usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
200 | operator<<(unsigned int __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'unsigned int'
200 | operator<<(unsigned int __n)
| ~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
211 | operator<<(long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'long long int'
211 | operator<<(long long __n)
| ~~~~~~~~~~^~~
/usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
215 | operator<<(unsigned long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'long long unsigned int'
215 | operator<<(unsigned long long __n)
| ~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
231 | operator<<(double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'double'
231 | operator<<(double __f)
| ~~~~~~~^~~
/usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
235 | operator<<(float __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'float'
235 | operator<<(float __f)
| ~~~~~~^~~
/usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
243 | operator<<(long double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'long double'
243 | operator<<(long double __f)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
301 | operator<<(const void* __p)
| ^~~~~~~~
/usr/include/c++/14/ostream:301:30: note: no known conversion for argument 1 from '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'const void*'
301 | operator<<(const void* __p)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:306:7: note: candida |
s800557543 | p04031 | C++ | #include<iostream>
#include<algorithm>
using namespace std;
int main(){
int N;
cin>>N;
int a[N];
vector<int> cost;
for(int i=0;i<N;i++)cin>>a[N];
for(int i=-100;i<=100;i++){
int temp=0;
for(int j=0;j<N;j++)temp+=((a[j]-i)*(a[j]-i));
cost.push_back(temp);
}
cout<<min_element(cost.begin(),cost.end())<<endl;
} | a.cc: In function 'int main()':
a.cc:8:3: error: 'vector' was not declared in this scope
8 | vector<int> cost;
| ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
2 | #include<algorithm>
+++ |+#include <vector>
3 | using namespace std;
a.cc:8:10: error: expected primary-expression before 'int'
8 | vector<int> cost;
| ^~~
a.cc:13:5: error: 'cost' was not declared in this scope; did you mean 'const'?
13 | cost.push_back(temp);
| ^~~~
| const
a.cc:15:21: error: 'cost' was not declared in this scope; did you mean 'const'?
15 | cout<<min_element(cost.begin(),cost.end())<<endl;
| ^~~~
| const
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.