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 << e...
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/...
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...
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...
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 = ...
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::...
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: no...
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++) { ...
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++){ ...
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.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 ...
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); } ...
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 | } ...
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) { ...
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> ...
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=...
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=-1...
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 ...
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...
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; #...
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); ...
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...
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....
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...
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,...
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; ...
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; ...
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...
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 inclu...
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...
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 f...
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 ...
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 ...
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 ...
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 RR...
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:...
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; ...
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....
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;...
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;...
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' ...
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(...
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...
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 ...
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 ...
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 <climi...
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 << accumul...
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...
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) { pri...
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){ | ^~~~~~~~~~~~~...
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); ...
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); ...
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)...
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)) ty...
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:5...
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;...
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...
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> ...
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...
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> ...
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...
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 ...
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...
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++){ in...
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; retu...
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:...
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;...
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, ...
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...
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 funct...
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...
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 functi...
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 ...
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; number...
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...
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 ...
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); ...
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)){ ...
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 (cn...
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)){ ...
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 (cn...
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]); } ...
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 ...
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]; } ...
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...
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.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...
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];} in...
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...
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...
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 <<...
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 subscri...
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];...
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....
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-...
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...
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 ...
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++){ cos...
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{}; ...
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); ...
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, ...
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 nu...
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; ...
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> ...
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 i...
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 += (...
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 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.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.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+...
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); } ...
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> ...
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); } st...
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 tar...
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))...
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))...
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(),co...
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_e...
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, ...
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_elemen...
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()); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ | | | ...
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_elemen...
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()) | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ | | | _...
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(...
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; | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ...
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...
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 ...