submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s766265526
p03659
C++
#include<iostream> #include<algorithm> #include<numeric> using namespace std; int main(){ int n; cin >> n; int a[n]; int ret=0; for(auto& x:a){ cin >>x; ret+=x; } int out=10000000; int sum=0; for(i=0;i<n-1;i++){ sum+=a[i]; out =min(out,abs(ret-2*sum)); } cout << out << endl; }
a.cc: In function 'int main()': a.cc:18:7: error: 'i' was not declared in this scope 18 | for(i=0;i<n-1;i++){ | ^
s728976561
p03659
C++
n=int(input()) a=list(map(int,input().split())) if n==2: print(abs(a[1]-a[0])) else: for i in range(n): if a[i]<0: a[i]=-a[i] else: break a.sort(reverse=True) snk=a[0] arg=a[1] for i in range(2,n): if snk>=arg: arg=arg+a[i] else: snk=snk+a[i] print(abs(snk-arg))
a.cc:1:1: error: 'n' does not name a type 1 | n=int(input()) | ^
s865094886
p03659
C++
#include <bits/stdc++.h> #define rep(i, n) for(int i = 0; i < n; i++) using namespace std; int main(void) { long long n, sum, ans, x, y; cin >> n; vector<long long> v(n); sum = 0; rep(i, n) { cin >> v[i]; sum += v[i]; } sort(v.rbegin(), v.rend()); ans = (int)1e9; x = y = 0; rep(i, n) { x = sum; y += v[j]; x -= y; ans = min(ans, abs(x - y)); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:23:24: error: 'j' was not declared in this scope 23 | y += v[j]; | ^
s365102879
p03659
C++
#include <bits/stdc++.h> using namespace std; #define all(v) v.begin(), v.end() #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define intll int long long const int INF = 1e9; const int MOD = 1e9 + 7; int main() { int n ; cin >> n ; vector<intll> v(n+1) ; v.at(0) = 0 ; rep(i,n){ int c ; cin >> c ; v.at(i+1) = v.at(i) + c ; } intll ans = INF; rep(i,n){ intll now =abs(v.at(n) -2*v.at(i+1)) ; ans = min (ans,now); } cout << ans ; }a
a.cc:32:2: error: 'a' does not name a type 32 | }a | ^
s181020232
p03659
C++
#include<bits/stdc++.h> #define rep(i,n)for(int i=0;i<n;++i) #include<string> #include<vector> using namespace std; typedef long long ll; typedef pair<int, int>P; template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } //max=({}); //条件式が真ならwhileの中身を回し続ける //printf("%d\n", ans); //pairの入力 //vector<pair<ll, ll>>work(n); //rep(i, n) { // ll a, b; // cin >> a >> b; // work[i] = make_pair(a, b); //for(auto p:mp)(mapの探索) //printf("%.10f\n",なんちゃら) int g[15][15]; const int INF = 1001001001; const int dx[4] = { -1,0,1,0 }; const int dy[4] = { 0,-1,0,1 }; //最大公約数 ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; } ll lcm(ll x, ll y) { if (x == 0 || y == 0)return 0; return (x / gcd(x, y) * y); } //素因数分解 vector<pair<ll, int>>factorize(ll n) { vector<pair<ll, int>>res; for (ll i = 2;i * i <= n;++i) { if (n % i)continue; res.emplace_back(i, 0); while (n % i == 0) { n /= i; res.back().second++; } } if (n != 1)res.emplace_back(n, 1); return res; } int bingo[3][3]; bool flag[3][3]; int cnt[2][105]; int h, w; int choco[1010][1010]; int s[11][11]; int main() { int n; cin >> n; vector<ll>a(n); ll total = 0, kuma = 0; ll ans = 0; rep(i, n) { cin >> a[i]; total += a[i]; } ll ans = 1e10; sort(a.begin(), a.end()); rep(i, n) { kuma += a[i]; ll res = abs(2 * kuma - total); ans = min(ans, res); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:70:12: error: redeclaration of 'll ans' 70 | ll ans = 1e10; | ^~~ a.cc:65:12: note: 'll ans' previously declared here 65 | ll ans = 0; | ^~~
s728073798
p03659
C++
//#define _GLIBCXX_DEBUG #include<bits/stdc++.h> #define PI 3.14159265359 using namespace std; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) const int INF= 1e9+5; typedef long long ll; typedef vector<ll> vl; typedef vector<vector<ll> >vvl; typedef pair<ll,ll> P; typedef tuple<ll,ll,ll> T; const ll MOD=1000000007LL; int main(){ ll n;cin>>n; vl a(n); rep(i,n)cin>>a[i]; ll arai=a[0]; rep(i,n)arai+=a[i]; arai-=a[0]; ll MIN=abs(arai-sunuke); for(ll i=1;i<n-1;i++){ arai-=a[i]; sunuke+=a[i]; MIN=min(abs(sunuke-arai),MIN); } cout<<MIN<<endl; }
a.cc: In function 'int main()': a.cc:21:19: error: 'sunuke' was not declared in this scope 21 | ll MIN=abs(arai-sunuke); | ^~~~~~
s312232132
p03659
C++
//#define _GLIBCXX_DEBUG #include<bits/stdc++.h> #define PI 3.14159265359 using namespace std; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) const int INF= 1e9+5; typedef long long ll; typedef vector<ll> vl; typedef vector<vector<ll> >vvl; typedef pair<ll,ll> P; typedef tuple<ll,ll,ll> T; const ll MOD=1000000007LL; int main(){ ll n;cin>>n; vl a(n); rep(i,n)cin>>a[i]; ll arai=0; ll sunuke=0; rep(i,n)arai+=a[i]; ll MIN=abs(arai-sunuke); rep(i,n){ arai-=a[i]; sunuke+=a[i]; MIN=min(abs(sunuke-arai)),MIN); } cout<<MIN<<endl; }
a.cc: In function 'int main()': a.cc:25:12: error: no matching function for call to 'min(long long int)' 25 | MIN=min(abs(sunuke-arai)),MIN); | ~~~^~~~~~~~~~~~~~~~~~ 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:3: /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: candidate expects 2 arguments, 1 provided /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, 1 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: template argument deduction/substitution failed: a.cc:25:12: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 25 | MIN=min(abs(sunuke-arai)),MIN); | ~~~^~~~~~~~~~~~~~~~~~ /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: candidate expects 2 arguments, 1 provided
s063415967
p03659
C++
#include<bits/stdc++.h> using namespace std; long long a[200010],ans[200010],sum,n,x,y; int main() { cin>>n; for(int i=0;i<n;i++) cin>>a[i],sum+=a[i]; x=a[0] y=sum-a[0]; ans[0]=abs(x-y); for(int i=1;i<n-1;i++) x+=a[i],y-=a[i],ans[i]=abs(x-y); sort(ans,ans+n-1); cout<<ans[0]<<endl; return 0; }
a.cc: In function 'int main()': a.cc:9:11: error: expected ';' before 'y' 9 | x=a[0] | ^ | ; 10 | y=sum-a[0]; | ~
s407173293
p03659
Java
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int N = sc.nextInt(); long[] a =new long[N]; long[] sumar = new long[N]; long sum =0; for(int i=0;i<N;i++) { a[i]=sc.nextLong(); sum += a[i]; sumar[i]= sum; } long ans =100000000000000; for(int i=0;i<N;i++) { if(Math.abs(sum-2*sumar[i])<ans) ans = Math.abs(sum-2*sumar[i]); } System.out.println(ans); } }
Main.java:17: error: integer number too large long ans =100000000000000; ^ 1 error
s283376054
p03659
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ ll n,c; cin >> n; vector<ll> a(n),b(n),c(n),d(n); for(ll i=0;i<n;i++){ cin >> a.at(i); c += a.at(i); } b.at(0) = a.at(0); for(ll i=1;i<n;i++){ b.at(i) = a.at(i) + b.at(i); c.at(i) = c - b.at(i); } for(ll i=1;i<n-1;i++){ d.at(i) = max(b.at(i) -c.at(i),c.at(i) -b.at(i)); } sort(d.begin(),d.end()); cout << d.at(0) << endl; return 0; }
a.cc: In function 'int main()': a.cc:8:24: error: conflicting declaration 'std::vector<long long int> c' 8 | vector<ll> a(n),b(n),c(n),d(n); | ^ a.cc:6:8: note: previous declaration as 'll c' 6 | ll n,c; | ^ a.cc:17:7: error: request for member 'at' in 'c', which is of non-class type 'll' {aka 'long long int'} 17 | c.at(i) = c - b.at(i); | ^~ a.cc:20:30: error: request for member 'at' in 'c', which is of non-class type 'll' {aka 'long long int'} 20 | d.at(i) = max(b.at(i) -c.at(i),c.at(i) -b.at(i)); | ^~ a.cc:20:38: error: request for member 'at' in 'c', which is of non-class type 'll' {aka 'long long int'} 20 | d.at(i) = max(b.at(i) -c.at(i),c.at(i) -b.at(i)); | ^~
s713990702
p03659
C++
#include<cstdio> #include<vector> #include<numeric> #include<algorithm> #include<cmath> int main(){ int n; std::cin >> n; std::vector<int> a(n); for(int i = 0; i < n; i++) std::cin >> a[i]; long long x = a[0]; long long y = std::accumulate(a.begin(), a.end()) - a[0]; long long ans = std::abs(y - x); for(int i = 1; i < n-1; i++){ x += a[i]; y -= a[i]; ans = std::min(ans, std::abs(y-x)); } }
a.cc: In function 'int main()': a.cc:9:10: error: 'cin' is not a member of 'std' 9 | std::cin >> n; | ^~~ a.cc:6:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 5 | #include<cmath> +++ |+#include <iostream> 6 | a.cc:12:37: error: 'cin' is not a member of 'std' 12 | for(int i = 0; i < n; i++) std::cin >> a[i]; | ^~~ a.cc:12:37: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:15:34: error: no matching function for call to 'accumulate(std::vector<int>::iterator, std::vector<int>::iterator)' 15 | long long y = std::accumulate(a.begin(), a.end()) - a[0]; | ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/numeric:62, from a.cc:3: /usr/include/c++/14/bits/stl_numeric.h:134:5: note: candidate: 'template<class _InputIterator, class _Tp> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp)' 134 | accumulate(_InputIterator __first, _InputIterator __last, _Tp __init) | ^~~~~~~~~~ /usr/include/c++/14/bits/stl_numeric.h:134:5: note: candidate expects 3 arguments, 2 provided /usr/include/c++/14/bits/stl_numeric.h:161:5: note: candidate: 'template<class _InputIterator, class _Tp, class _BinaryOperation> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp, _BinaryOperation)' 161 | accumulate(_InputIterator __first, _InputIterator __last, _Tp __init, | ^~~~~~~~~~ /usr/include/c++/14/bits/stl_numeric.h:161:5: note: candidate expects 4 arguments, 2 provided
s416688805
p03659
Java
java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.NoSuchElementException; import java.util.function.BiFunction; import java.util.function.Consumer; import java.util.function.Supplier; public class Main { final static long MOD07 = 1_000_000_007; final static long MOD09 = 1_000_000_009; public static void main(String[] args) { final FastScanner fs = new FastScanner(); int N = fs.nextInt(); int[] a = new int[N]; for (int i = 0; i < N; i++) { a[i] = fs.nextInt(); } long[] prefixSum = new long[N+1]; prefixSum[0] = 0; for (int i = 0; i < N; i++) { prefixSum[i+1] = prefixSum[i] + a[i]; } long min = Integer.MAX_VALUE; for (int i = 1; i < N; i++) { long x = prefixSum[i] - prefixSum[0]; long y = prefixSum[N] - prefixSum[i]; min = Math.min(min, Math.abs(x - y)); } PrintWriter out = new PrintWriter(System.out); out.println(min); out.flush(); } static void debug(Object... os) { System.err.println(Arrays.deepToString(os)); } // Execute func for all patterns can be represented with n bit. // O(n2^n) static void forAllBit(int n, Consumer<List<Boolean>> func) { for (int i = 0; i < (1 << n); i++) { List<Boolean> arg = new ArrayList(); for (int j = 0; j < n; j++) { boolean isJthBitSet = ((i >> j) & 1) == 1; arg.add(isJthBitSet); } func.accept(arg); } } static class Pair<F extends Comparable<F>, S extends Comparable<S>> implements Comparable<Pair<F, S>> { F f; S s; Pair() { } Pair(F f, S s) { this.f = f; this.s = s; } Pair(Pair<F, S> p) { f = p.f; s = p.s; } @Override public int compareTo(Pair<F, S> p) { if (f.compareTo(p.f) != 0) { return f.compareTo(p.f); } return s.compareTo(p.s); } @Override public int hashCode() { return f.hashCode() ^ s.hashCode(); } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || this.f == null || this.s == null) { return false; } if (this.getClass() != o.getClass()) { return false; } Pair p = (Pair) o; return this.f.equals(p.f) && this.s.equals(p.s); } @Override public String toString() { return "{" + f.toString() + ", " + s.toString() + "}"; } } public static int gcd(int a, int b) { if (b == 0) { return a; } return gcd(b, a % b); } public static boolean isPrime(int n) { for (int i = 2; i <= ((int) Math.sqrt(n)); i++) { if (n % i == 0) { return false; } } return n != 1; } public static void reverse(int[] array) { for (int i = 0; i < array.length / 2; i++) { int temp = array[i]; array[i] = array[array.length - i - 1]; array[array.length - i - 1] = temp; } } public static void reverse(long[] array) { for (int i = 0; i < array.length / 2; i++) { long temp = array[i]; array[i] = array[array.length - i - 1]; array[array.length - i - 1] = temp; } } public static boolean isPrime(long n) { for (long i = 2; i <= ((long) Math.sqrt(n)); i++) { if (n % i == 0) { return false; } } return n != 1; } public static Map<Long, Long> primeFactor(long n) { Map<Long, Long> map = new HashMap<>(); long num = n; for (long i = 2; i <= ((long) Math.sqrt(n)); i++) { while (num % i == 0L) { map.put(i, map.getOrDefault(i, 0L) + 1L); num /= i; } } if (num != 1) { map.put(num, 1L); } return map; } public static List<Long> divisors(long n) { List<Long> list = new ArrayList<>(); for (long i = 1; i <= ((long) Math.sqrt(n)); i++) { if (n % i == 0) { list.add(i); if (i != n / i) { list.add(n / i); } } } return list; } public static int lcm(int a, int b) { return a / gcd(a, b) * b; } public static int nCk(int n, int k, int M) { long ret = 1; int min = Math.min(k, n - k); for (int i = 1; i <= min; i++) { ret = (ret * pow(i, M - 2, M)) % M; } for (int i = n - min + 1; i <= n; i++) { ret = (ret * i) % M; } return (int) ret; } //return a^b mod M O(logB) public static long pow(long a, long b, int M) { long ret = 1; long tmp = a; while (b > 0) { if ((b & 1) == 1) ret = (ret * tmp) % M; tmp = (tmp * tmp) % M; b = b >> 1; } return ret; } public static int find(int[] tree, int idx) { if (tree[idx] == idx) return idx; else return tree[idx] = find(tree, tree[idx]); } public static void union(int[] tree, int idx1, int idx2) { int root1 = find(tree, idx1); int root2 = find(tree, idx2); tree[root2] = root1; } public static int lowerBound(int[] list, int target) { int ok = list.length; int ng = -1; while (Math.abs(ok - ng) > 1) { int mid = (ok + ng) / 2; if (list[mid] >= target) { ok = mid; } else { ng = mid; } } return ok; } public static int lowerBound(long[] list, long target) { int ok = list.length; int ng = -1; while (Math.abs(ok - ng) > 1) { int mid = (ok + ng) / 2; if (list[mid] >= target) { ok = mid; } else { ng = mid; } } return ok; } public static <T extends Comparable<? super T>> int lowerBound(List<T> list, T target) { return ~Collections.binarySearch(list, target, (x, y) -> (x.compareTo(y) >= 0) ? 1 : -1); } public static <T extends Comparable<? super T>> int upperBound(List<T> list, T target) { return ~Collections.binarySearch(list, target, (x, y) -> (x.compareTo(y) > 0) ? 1 : -1); } } 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 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()); } } class BIT<T> { int n; ArrayList<T> bit; BiFunction<T, T, T> bif; /** * 1-indexed なBinary Indexed Treeを構築する * * @param n 容量 * @param bif 適用させる関数 * @param sup 初期値 */ BIT(int n, BiFunction<T, T, T> bif, Supplier<T> sup) { this.n = n; bit = new ArrayList<>(n + 1); for (int i = 0; i < n + 1; ++i) { bit.add(sup.get()); } this.bif = bif; } /** * iの位置の値をvで更新する * * @param i index * @param v 新しい値 */ void set(int i, T v) { for (int x = i; x <= n; x += x & -x) { bit.set(x, bif.apply(bit.get(x), v)); } } /** * クエリー * * @param defaultValue 初期値 * @param i index * @return [1, i]までfを適用した結果 */ T reduce(T defaultValue, int i) { T ret = defaultValue; for (int x = i; x > 0; x -= x & -x) { ret = bif.apply(ret, bit.get(x)); } return ret; } } class SegmentTree<T> { int n; ArrayList<T> dat; BiFunction<T, T, T> bif; Supplier<T> sup; /** * 0-indexed なSegment Treeを構築する * * @param n_ 要求容量 * @param bif 適用させる関数 * @param sup 初期値 */ SegmentTree(int n_, BiFunction<T, T, T> bif, Supplier<T> sup) { n = 1; while (n < n_) n *= 2; dat = new ArrayList<>(2 * n - 1); for (int i = 0; i < 2 * n - 1; ++i) { dat.add(sup.get()); } this.bif = bif; this.sup = sup; } /** * kの位置の値をvで更新する * * @param k index * @param v 新しい値 */ void set(int k, T v) { k += n - 1; dat.set(k, v); while (k > 0) { k = (k - 1) / 2; dat.set(k, bif.apply(dat.get(k * 2 + 1), dat.get(k * 2 + 2))); } } /** * クエリー * * @param l はじめ * @param r おわり * @return [l, r)での演算bifを適用した結果を返す */ T reduce(int l, int r) { return _reduce(l, r, 0, 0, n); } T _reduce(int a, int b, int k, int l, int r) { if (r <= a || b <= l) return sup.get(); if (a <= l && r <= b) return dat.get(k); T vl = _reduce(a, b, k * 2 + 1, l, (l + r) / 2); T vr = _reduce(a, b, k * 2 + 2, (l + r) / 2, r); return bif.apply(vl, vr); } } class UnionFind { int[] par; UnionFind(int n) { par = new int[n]; for (int i = 0; i < n; ++i) { par[i] = i; } } int find(int x) { if (par[x] == x) { return x; } return par[x] = find(par[x]); } boolean same(int x, int y) { return find(x) == find(y); } void union(int x, int y) { x = find(x); y = find(y); if (x == y) { return; } par[x] = y; } }
Main.java:1: error: class, interface, enum, or record expected java.io.IOException; ^ Main.java:2: error: class, interface, enum, or record expected import java.io.InputStream; ^ Main.java:3: error: class, interface, enum, or record expected import java.io.PrintWriter; ^ Main.java:4: error: class, interface, enum, or record expected import java.util.ArrayList; ^ Main.java:5: error: class, interface, enum, or record expected import java.util.Arrays; ^ Main.java:6: error: class, interface, enum, or record expected import java.util.Collections; ^ Main.java:7: error: class, interface, enum, or record expected import java.util.HashMap; ^ Main.java:8: error: class, interface, enum, or record expected import java.util.List; ^ Main.java:9: error: class, interface, enum, or record expected import java.util.Map; ^ Main.java:10: error: class, interface, enum, or record expected import java.util.NoSuchElementException; ^ Main.java:11: error: class, interface, enum, or record expected import java.util.function.BiFunction; ^ Main.java:12: error: class, interface, enum, or record expected import java.util.function.Consumer; ^ Main.java:13: error: class, interface, enum, or record expected import java.util.function.Supplier; ^ 13 errors
s266284492
p03659
Java
public class Main { final static long MOD07 = 1_000_000_007; final static long MOD09 = 1_000_000_009; public static void main(String[] args) { final FastScanner fs = new FastScanner(); int N = fs.nextInt(); int[] a = new int[N]; for (int i = 0; i < N; i++) { a[i] = fs.nextInt(); } long[] prefixSum = new long[N+1]; prefixSum[0] = 0; for (int i = 0; i < N; i++) { prefixSum[i+1] = prefixSum[i] + a[i]; } long min = Integer.MAX_VALUE; for (int i = 1; i < N; i++) { long x = prefixSum[i] - prefixSum[0]; long y = prefixSum[N] - prefixSum[i]; min = Math.min(min, Math.abs(x - y)); } PrintWriter out = new PrintWriter(System.out); out.println(min); out.flush(); } static void debug(Object... os) { System.err.println(Arrays.deepToString(os)); } // Execute func for all patterns can be represented with n bit. // O(n2^n) static void forAllBit(int n, Consumer<List<Boolean>> func) { for (int i = 0; i < (1 << n); i++) { List<Boolean> arg = new ArrayList(); for (int j = 0; j < n; j++) { boolean isJthBitSet = ((i >> j) & 1) == 1; arg.add(isJthBitSet); } func.accept(arg); } } static class Pair<F extends Comparable<F>, S extends Comparable<S>> implements Comparable<Pair<F, S>> { F f; S s; Pair() { } Pair(F f, S s) { this.f = f; this.s = s; } Pair(Pair<F, S> p) { f = p.f; s = p.s; } @Override public int compareTo(Pair<F, S> p) { if (f.compareTo(p.f) != 0) { return f.compareTo(p.f); } return s.compareTo(p.s); } @Override public int hashCode() { return f.hashCode() ^ s.hashCode(); } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || this.f == null || this.s == null) { return false; } if (this.getClass() != o.getClass()) { return false; } Pair p = (Pair) o; return this.f.equals(p.f) && this.s.equals(p.s); } @Override public String toString() { return "{" + f.toString() + ", " + s.toString() + "}"; } } public static int gcd(int a, int b) { if (b == 0) { return a; } return gcd(b, a % b); } public static boolean isPrime(int n) { for (int i = 2; i <= ((int) Math.sqrt(n)); i++) { if (n % i == 0) { return false; } } return n != 1; } public static void reverse(int[] array) { for (int i = 0; i < array.length / 2; i++) { int temp = array[i]; array[i] = array[array.length - i - 1]; array[array.length - i - 1] = temp; } } public static void reverse(long[] array) { for (int i = 0; i < array.length / 2; i++) { long temp = array[i]; array[i] = array[array.length - i - 1]; array[array.length - i - 1] = temp; } } public static boolean isPrime(long n) { for (long i = 2; i <= ((long) Math.sqrt(n)); i++) { if (n % i == 0) { return false; } } return n != 1; } public static Map<Long, Long> primeFactor(long n) { Map<Long, Long> map = new HashMap<>(); long num = n; for (long i = 2; i <= ((long) Math.sqrt(n)); i++) { while (num % i == 0L) { map.put(i, map.getOrDefault(i, 0L) + 1L); num /= i; } } if (num != 1) { map.put(num, 1L); } return map; } public static List<Long> divisors(long n) { List<Long> list = new ArrayList<>(); for (long i = 1; i <= ((long) Math.sqrt(n)); i++) { if (n % i == 0) { list.add(i); if (i != n / i) { list.add(n / i); } } } return list; } public static int lcm(int a, int b) { return a / gcd(a, b) * b; } public static int nCk(int n, int k, int M) { long ret = 1; int min = Math.min(k, n - k); for (int i = 1; i <= min; i++) { ret = (ret * pow(i, M - 2, M)) % M; } for (int i = n - min + 1; i <= n; i++) { ret = (ret * i) % M; } return (int) ret; } //return a^b mod M O(logB) public static long pow(long a, long b, int M) { long ret = 1; long tmp = a; while (b > 0) { if ((b & 1) == 1) ret = (ret * tmp) % M; tmp = (tmp * tmp) % M; b = b >> 1; } return ret; } public static int find(int[] tree, int idx) { if (tree[idx] == idx) return idx; else return tree[idx] = find(tree, tree[idx]); } public static void union(int[] tree, int idx1, int idx2) { int root1 = find(tree, idx1); int root2 = find(tree, idx2); tree[root2] = root1; } public static int lowerBound(int[] list, int target) { int ok = list.length; int ng = -1; while (Math.abs(ok - ng) > 1) { int mid = (ok + ng) / 2; if (list[mid] >= target) { ok = mid; } else { ng = mid; } } return ok; } public static int lowerBound(long[] list, long target) { int ok = list.length; int ng = -1; while (Math.abs(ok - ng) > 1) { int mid = (ok + ng) / 2; if (list[mid] >= target) { ok = mid; } else { ng = mid; } } return ok; } public static <T extends Comparable<? super T>> int lowerBound(List<T> list, T target) { return ~Collections.binarySearch(list, target, (x, y) -> (x.compareTo(y) >= 0) ? 1 : -1); } public static <T extends Comparable<? super T>> int upperBound(List<T> list, T target) { return ~Collections.binarySearch(list, target, (x, y) -> (x.compareTo(y) > 0) ? 1 : -1); } } 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 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()); } } class BIT<T> { int n; ArrayList<T> bit; BiFunction<T, T, T> bif; /** * 1-indexed なBinary Indexed Treeを構築する * * @param n 容量 * @param bif 適用させる関数 * @param sup 初期値 */ BIT(int n, BiFunction<T, T, T> bif, Supplier<T> sup) { this.n = n; bit = new ArrayList<>(n + 1); for (int i = 0; i < n + 1; ++i) { bit.add(sup.get()); } this.bif = bif; } /** * iの位置の値をvで更新する * * @param i index * @param v 新しい値 */ void set(int i, T v) { for (int x = i; x <= n; x += x & -x) { bit.set(x, bif.apply(bit.get(x), v)); } } /** * クエリー * * @param defaultValue 初期値 * @param i index * @return [1, i]までfを適用した結果 */ T reduce(T defaultValue, int i) { T ret = defaultValue; for (int x = i; x > 0; x -= x & -x) { ret = bif.apply(ret, bit.get(x)); } return ret; } } class SegmentTree<T> { int n; ArrayList<T> dat; BiFunction<T, T, T> bif; Supplier<T> sup; /** * 0-indexed なSegment Treeを構築する * * @param n_ 要求容量 * @param bif 適用させる関数 * @param sup 初期値 */ SegmentTree(int n_, BiFunction<T, T, T> bif, Supplier<T> sup) { n = 1; while (n < n_) n *= 2; dat = new ArrayList<>(2 * n - 1); for (int i = 0; i < 2 * n - 1; ++i) { dat.add(sup.get()); } this.bif = bif; this.sup = sup; } /** * kの位置の値をvで更新する * * @param k index * @param v 新しい値 */ void set(int k, T v) { k += n - 1; dat.set(k, v); while (k > 0) { k = (k - 1) / 2; dat.set(k, bif.apply(dat.get(k * 2 + 1), dat.get(k * 2 + 2))); } } /** * クエリー * * @param l はじめ * @param r おわり * @return [l, r)での演算bifを適用した結果を返す */ T reduce(int l, int r) { return _reduce(l, r, 0, 0, n); } T _reduce(int a, int b, int k, int l, int r) { if (r <= a || b <= l) return sup.get(); if (a <= l && r <= b) return dat.get(k); T vl = _reduce(a, b, k * 2 + 1, l, (l + r) / 2); T vr = _reduce(a, b, k * 2 + 2, (l + r) / 2, r); return bif.apply(vl, vr); } } class UnionFind { int[] par; UnionFind(int n) { par = new int[n]; for (int i = 0; i < n; ++i) { par[i] = i; } } int find(int x) { if (par[x] == x) { return x; } return par[x] = find(par[x]); } boolean same(int x, int y) { return find(x) == find(y); } void union(int x, int y) { x = find(x); y = find(y); if (x == y) { return; } par[x] = y; } }
Main.java:40: error: cannot find symbol static void forAllBit(int n, Consumer<List<Boolean>> func) { ^ symbol: class Consumer location: class Main Main.java:40: error: cannot find symbol static void forAllBit(int n, Consumer<List<Boolean>> func) { ^ symbol: class List location: class Main Main.java:143: error: cannot find symbol public static Map<Long, Long> primeFactor(long n) { ^ symbol: class Map location: class Main Main.java:159: error: cannot find symbol public static List<Long> divisors(long n) { ^ symbol: class List location: class Main Main.java:241: error: cannot find symbol public static <T extends Comparable<? super T>> int lowerBound(List<T> list, T target) { ^ symbol: class List location: class Main Main.java:245: error: cannot find symbol public static <T extends Comparable<? super T>> int upperBound(List<T> list, T target) { ^ symbol: class List location: class Main Main.java:252: error: cannot find symbol private final InputStream in = System.in; ^ symbol: class InputStream location: class FastScanner Main.java:337: error: cannot find symbol ArrayList<T> bit; ^ symbol: class ArrayList location: class BIT<T> where T is a type-variable: T extends Object declared in class BIT Main.java:338: error: cannot find symbol BiFunction<T, T, T> bif; ^ symbol: class BiFunction location: class BIT<T> where T is a type-variable: T extends Object declared in class BIT Main.java:347: error: cannot find symbol BIT(int n, BiFunction<T, T, T> bif, Supplier<T> sup) { ^ symbol: class BiFunction location: class BIT<T> where T is a type-variable: T extends Object declared in class BIT Main.java:347: error: cannot find symbol BIT(int n, BiFunction<T, T, T> bif, Supplier<T> sup) { ^ symbol: class Supplier location: class BIT<T> where T is a type-variable: T extends Object declared in class BIT Main.java:386: error: cannot find symbol ArrayList<T> dat; ^ symbol: class ArrayList location: class SegmentTree<T> where T is a type-variable: T extends Object declared in class SegmentTree Main.java:387: error: cannot find symbol BiFunction<T, T, T> bif; ^ symbol: class BiFunction location: class SegmentTree<T> where T is a type-variable: T extends Object declared in class SegmentTree Main.java:388: error: cannot find symbol Supplier<T> sup; ^ symbol: class Supplier location: class SegmentTree<T> where T is a type-variable: T extends Object declared in class SegmentTree Main.java:397: error: cannot find symbol SegmentTree(int n_, BiFunction<T, T, T> bif, Supplier<T> sup) { ^ symbol: class BiFunction location: class SegmentTree<T> where T is a type-variable: T extends Object declared in class SegmentTree Main.java:397: error: cannot find symbol SegmentTree(int n_, BiFunction<T, T, T> bif, Supplier<T> sup) { ^ symbol: class Supplier location: class SegmentTree<T> where T is a type-variable: T extends Object declared in class SegmentTree Main.java:28: error: cannot find symbol PrintWriter out = new PrintWriter(System.out); ^ symbol: class PrintWriter location: class Main Main.java:28: error: cannot find symbol PrintWriter out = new PrintWriter(System.out); ^ symbol: class PrintWriter location: class Main Main.java:35: error: cannot find symbol System.err.println(Arrays.deepToString(os)); ^ symbol: variable Arrays location: class Main Main.java:42: error: cannot find symbol List<Boolean> arg = new ArrayList(); ^ symbol: class List location: class Main Main.java:42: error: cannot find symbol List<Boolean> arg = new ArrayList(); ^ symbol: class ArrayList location: class Main Main.java:144: error: cannot find symbol Map<Long, Long> map = new HashMap<>(); ^ symbol: class Map location: class Main Main.java:144: error: cannot find symbol Map<Long, Long> map = new HashMap<>(); ^ symbol: class HashMap location: class Main Main.java:160: error: cannot find symbol List<Long> list = new ArrayList<>(); ^ symbol: class List location: class Main Main.java:160: error: cannot find symbol List<Long> list = new ArrayList<>(); ^ symbol: class ArrayList location: class Main Main.java:242: error: cannot find symbol return ~Collections.binarySearch(list, target, (x, y) -> (x.compareTo(y) >= 0) ? 1 : -1); ^ symbol: variable Collections location: class Main Main.java:246: error: cannot find symbol return ~Collections.binarySearch(list, target, (x, y) -> (x.compareTo(y) > 0) ? 1 : -1); ^ symbol: variable Collections location: class Main Main.java:264: error: cannot find symbol } catch (IOException e) { ^ symbol: class IOException location: class FastScanner Main.java:289: error: cannot find symbol if (!hasNext()) throw new NoSuchElementException(); ^ symbol: class NoSuchElementException location: class FastScanner Main.java:300: error: cannot find symbol if (!hasNext()) throw new NoSuchElementException(); ^ symbol: class NoSuchElementException location: class FastScanner Main.java:349: error: cannot find symbol bit = new ArrayList<>(n + 1); ^ symbol: class ArrayList location: class BIT<T> where T is a type-variable: T extends Object declared in class BIT Main.java:401: error: cannot find symbol dat = new ArrayList<>(2 * n - 1); ^ symbol: class ArrayList location: class SegmentTree<T> where T is a type-variable: T extends Object declared in class SegmentTree 32 errors
s054687501
p03659
C++
#include<bits/stdc++.h> using namespace std; #define ll long long // long long省略 #define pb push_back // push_back省略 #define mp make_pair // make_pair省略 #define fi first // first省略 #define se second // second省略 #define itn int // int誤字保険 #define count cout // cout誤字保険 #define vecotr vector // vector誤字保険 #define ednl endl // endl誤字保険 #define opt() cin.tie(0); ios::sync_with_stdio(false) // 入出力速度改善 #define rep(i,l,r) for(ll i=(l);i<(r);i++) // 範囲[l, r)で刻み1のfor文(順方向) #define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k)) // 範囲[l, r)で刻みkのfor文(順方向) #define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--) // 範囲[l, r)で刻み1のfor文(逆方向) #define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k)) // 範囲[l, r)で刻みkのfor文(逆方向) #define all(x) (x).begin(), (x).end() // vectorのポインタ位置指定用 #define max(p,q)((p)>(q)?(p):(q)) // max拡張 #define min(p,q)((p)<(q)?(p):(q)) // min拡張 #define bit(n,m)(((n)>>(m))&1) // 変数nのm番目のbitを取り出す 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 dy[]={0, 1, 0, -1}; // 4方向近傍 int dx[]={1, 0, -1, 0}; // 4方向近傍 #define INF ((1LL<<62)-(1LL<<31)) //#define MOD 998244353 #define MOD 1000000007 #define invp(a,p) pom(a,p-2,p) //////////////////////////////////////////////////////////////////////////////////////// int main(){ ll n; cin >> n; ll a[n]; rep(i,0,n) cin >> a[i]; ll sum = 0; rep(i,0,n) sum += a[i]; ll csum[n]; csum[0] = a[0]; rep(i,1,n) csum[i] = a[i]+ a[i-1]; ll res = INF; rep(i,0,n){ res = min(res, abs(sum - csum*2)); } cout << res << endl; }
a.cc: In function 'int main()': a.cc:44:38: error: invalid operands of types 'long long int [n]' and 'int' to binary 'operator*' 44 | res = min(res, abs(sum - csum*2)); | ~~~~^~ | | | | | int | long long int [n] a.cc:20:23: note: in definition of macro 'min' 20 | #define min(p,q)((p)<(q)?(p):(q)) // min拡張 | ^ a.cc:44:38: error: invalid operands of types 'long long int [n]' and 'int' to binary 'operator*' 44 | res = min(res, abs(sum - csum*2)); | ~~~~^~ | | | | | int | long long int [n] a.cc:20:31: note: in definition of macro 'min' 20 | #define min(p,q)((p)<(q)?(p):(q)) // min拡張 | ^
s374385049
p03659
C
#include <stdio.h> int v[212345]; int main(){ int n; long long resposta, total = 0; scanf("%d", &n); for (int i = 0; i < n; i++){ scanf("%d", &v[i]); total += v[i]; } long long rogerio = total, mathias = 0; for (int i = 0; i <= n-2; ++i){ mathias += v[i]; rogerio -= v[i]; long long diferenca = mathias - rogerio; if (diferenca < 0) diferenca *= -1; if (i == 0 || (i != 0 && resposta > diferenca)) resposta = diferenca; } printf("%lld\n", diferenca); return 0; }
main.c: In function 'main': main.c:23:22: error: 'diferenca' undeclared (first use in this function) 23 | printf("%lld\n", diferenca); | ^~~~~~~~~ main.c:23:22: note: each undeclared identifier is reported only once for each function it appears in
s654271553
p03659
C
#include <stdio.h> int main(){ int i, n, sum = 0; scanf("%d", &n); int a[n]; for (i = 0; i < n; i++){ scanf("%d", &a[i]); sum += a[i]; } if (!sum%2){ for (i = 0; sum2 < sum; i++){ sum2 += a[i]; } } return 0; }
main.c: In function 'main': main.c:14:29: error: 'sum2' undeclared (first use in this function); did you mean 'sum'? 14 | for (i = 0; sum2 < sum; i++){ | ^~~~ | sum main.c:14:29: note: each undeclared identifier is reported only once for each function it appears in
s790796709
p03659
C
#include <stdio.h> int main(){ int n, somatotal=0,equilibrio; scanf("%d", &n); int vetor[n]; for(int i=0;i<n;i++){ scanf("%d", &vetor[i]); somatotal=somatotal+vetor[i]; } equilibrio=somatotal/2; int c=0; int fpartemathias; for(int partemathias=0;(partemathias<equilibrio)||(c<n);c++){ partemathias=partemathias+vetor[c]; fpartemathias=partemathias; } int fparterogerio; for(int parterogerio=0;c<=n;c++){ parterogerio=parterogerio+vetor[c]; fparterogerio=parterogerio; } int diferenca=parterogerio-partemathias; if(diferenca<0){ diferenca=diferenca*(-1); } printf("%d\n", diferenca); return 0; }
main.c: In function 'main': main.c:24:19: error: 'parterogerio' undeclared (first use in this function); did you mean 'fparterogerio'? 24 | int diferenca=parterogerio-partemathias; | ^~~~~~~~~~~~ | fparterogerio main.c:24:19: note: each undeclared identifier is reported only once for each function it appears in main.c:24:32: error: 'partemathias' undeclared (first use in this function); did you mean 'fpartemathias'? 24 | int diferenca=parterogerio-partemathias; | ^~~~~~~~~~~~ | fpartemathias
s413943228
p03659
C++
/*Function Template*/ #include<bits/stdc++.h> using namespace std; const int mod = 1000000007; #define rep(i, n) for(int i = 0; i < (n); i++) int Len(int n) { int s=0; while(n!=0) s++, n/=10; return s; } int Sint(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 Factorial(int n){ int m=1; while(n>=1) m*=n,n--; return m; } long long int Svec(vector<long long int> v){ long long int n=0; for(long long int i=0;i<v.size();i++) n+=v[i]; return n; } /*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/ int main() { long long int n,left=0,right=0,ans=2000000001; cin>>n; vector<long long int> v(n); rep(i,n) cin>>v[i]; sort(v.begin(),v.end()); right=Svec(v)-v[0]; left=v[0] rep(i,n){ ans=min(ans,abs(right-left)); right-=v[i]; left+=v[i]; } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:65:12: error: expected ';' before 'for' 65 | left=v[0] | ^ | ; a.cc:66:7: error: 'i' was not declared in this scope 66 | rep(i,n){ | ^ a.cc:5:34: note: in definition of macro 'rep' 5 | #define rep(i, n) for(int i = 0; i < (n); i++) | ^
s491563618
p03659
C++
/*Function Template*/ #include<bits/stdc++.h> using namespace std; const int mod = 1000000007; #define rep(i, n) for(int i = 0; i < (n); i++) int Len(int n) { int s=0; while(n!=0) s++, n/=10; return s; } int Sint(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 Factorial(int n){ int m=1; while(n>=1) m*=n,n--; return m; } long long int Svec(vector<long long int> v){ long long int n=0; for(long long int i=0;i<v.size();i++) n+=v[i]; return n; } /*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/ int main() { long long int n,left=0,right=0,ans=2000000001; cin>>n; vector<int> v(n); rep(i,n) cin>>v[i]; right=Svec(v); rep(i,n){ ans=min(ans,abs(left-right)); right-=v[i]; left+=v[i]; } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:63:14: error: could not convert 'v' from 'vector<int>' to 'vector<long long int>' 63 | right=Svec(v); | ^ | | | vector<int>
s416393564
p03659
C++
#include<iostream> #include<cstdio> #include<vector> #include<string> #include<algorithm> #include<cmath> using namespace std; typedef long long ll; const int INF = 1e9+1; template <class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return 1;} return 0;} template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;} int N, M; int main() { cin >> N; vector<ll> a(N); for (int i = 0; i < N; i++) cin >> a[i]; vector<ll> left(N), right(N); left[0] = a[0]; for (int i = 1; i < N; i++) { left[i] = left[i-1] + a[i]; } right[N-1] = a[N-1]; for (int i = N-2; i >= 0; i--) { right[i] = right[i+1] + a[i]; } int res = INF; for (int i = 0; i < N-1; i++) { chmin(res,abs(right[i+1]-left[i])); } cout << res << endl; }
a.cc: In function 'int main()': a.cc:33:14: error: no matching function for call to 'chmin(int&, long long int)' 33 | chmin(res,abs(right[i+1]-left[i])); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:14:32: note: candidate: 'template<class T> bool chmin(T&, T)' 14 | template <class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return 1;} return 0;} | ^~~~~ a.cc:14:32: note: template argument deduction/substitution failed: a.cc:33:14: note: deduced conflicting types for parameter 'T' ('int' and 'long long int') 33 | chmin(res,abs(right[i+1]-left[i])); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s168410474
p03659
C++
#include <bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; int a,sum[200000]; long long ans=20000000000; for(int i=0;i<n;i++){ cin>>a; sum[i]=a; if(i)sum+=sum[i-1]; } for(int i=0;i<n-1;i++){ ans=min(ans,abs(sum[n-1]-2*sum[i])); } cout<<ans; }
a.cc: In function 'int main()': a.cc:10:13: error: incompatible types in assignment of 'int' to 'int [200000]' 10 | if(i)sum+=sum[i-1]; | ~~~^~~~~~~~~~ a.cc:13:12: error: no matching function for call to 'min(long long int&, int)' 13 | ans=min(ans,abs(sum[n-1]-2*sum[i])); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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:13:12: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 13 | ans=min(ans,abs(sum[n-1]-2*sum[i])); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /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:13:12: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 13 | ans=min(ans,abs(sum[n-1]-2*sum[i])); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
s090401675
p03659
C++
#include <bits/stec++.h> using namespace std; int main(){ int n; cin>>n; int a,sum[200000]; long long ans=20000000000; for(int i=0;i<n;i++){ cin>>a; sum[i]=a; if(i)sum+=sum[i-1]; } for(int i=0;i<n-1;i++){ ans=min(ans,abs(sum[n-1]-2*sum[i])); } cout<<ans; }
a.cc:1:10: fatal error: bits/stec++.h: No such file or directory 1 | #include <bits/stec++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s560177390
p03659
C++
#include <bits/stdc++.h> #include <stdio.h> #include <algorithm> #include <map> using namespace std; #define r(i,n) for(int i=0;i<n;i++) #define ll long long #define rn(i,n) for(int i=1;i<=n;i++) int main (){ int n; cin>>n; vector<ll> a(n); ll sum=0,mini==1000000000000000000LL; r(i,n){ cin>>a.at(i); sum+=a.at(i); } ll sum1=0; r(i,n-1){ sum1+=a.at(i); if(mini>=abs(sum-2*sum1))mini=abs(sum-2*sum1); //cout<<mini<<endl; } cout<<mini<<endl; return 0; }
a.cc: In function 'int main()': a.cc:17:16: error: expected initializer before '==' token 17 | ll sum=0,mini==1000000000000000000LL; | ^~ a.cc:27:8: error: 'mini' was not declared in this scope 27 | if(mini>=abs(sum-2*sum1))mini=abs(sum-2*sum1); | ^~~~ a.cc:31:9: error: 'mini' was not declared in this scope 31 | cout<<mini<<endl; | ^~~~
s788479312
p03659
C++
#include<iostream> #include<cstdio> #include<algorithm> #include<cmath> #include<cstring> using namespace std; const int MAXN=2e5+5; long long a[MAXN],b[MAXN],ans=0; int main(){ ios::sync_with_stdio(false); int n; cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; b[i]=b[i-1]+a[i]; ans+=a[i]; } long long cmin=INT_MAX; for(int i=1;i<n;i++) if(cmin>abs(2*b[i]-ans)) cmin=abs(2*b[i]-ans); cout<<cmin<<endl; return 0; }
a.cc: In function 'int main()': a.cc:18:20: error: 'INT_MAX' was not declared in this scope 18 | long long cmin=INT_MAX; | ^~~~~~~ a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 5 | #include<cstring> +++ |+#include <climits> 6 | using namespace std;
s936329280
p03659
C++
#include <bits/stdc++.h> #define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i) #define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i) #define debug(x) cerr << #x << " = " << x << "\n" #define debugv(x) \ rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ") #define all(x) x.begin(), x.end() #define int long long using namespace std; typedef pair<int, int> pii; typedef vector<int> vi; const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7; int N, M, K; vi A, B; void input() { cin >> N; A.resize(N); rep(i, 0, N - 1) { cin >> A[i]; } } void solve() { B.resize(N); B[0] = A[0]; rep(i, 1, N) { B[i] = B[i - 1] + A[i]; } int ans = INF; rep(i, 0, N - 3) { ans = min(ans, abs(B[i] - (B[N - 1] - B[i + 1]))); } if (N == 2) { ans = abs(A[0] - A[1]); } else if (N == 3) { ans = min(abs((A[0] + A[1]) - A[2])); ans = min(abs(A[0] - (A[1] + A[2]))); } cout << ans << endl; ; ; } signed main() { input(); solve(); return 0; }
a.cc: In function 'void solve()': a.cc:32:14: error: no matching function for call to 'min(long long int)' 32 | ans = min(abs((A[0] + A[1]) - A[2])); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ 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: candidate expects 2 arguments, 1 provided /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, 1 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: template argument deduction/substitution failed: a.cc:32:14: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 32 | ans = min(abs((A[0] + A[1]) - A[2])); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ /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: candidate expects 2 arguments, 1 provided a.cc:33:14: error: no matching function for call to 'min(long long int)' 33 | ans = min(abs(A[0] - (A[1] + A[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: candidate expects 2 arguments, 1 provided /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, 1 provided /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: template argument deduction/substitution failed: a.cc:33:14: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int' 33 | ans = min(abs(A[0] - (A[1] + A[2]))); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ /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: candidate expects 2 arguments, 1 provided
s308778304
p03659
C++
#include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int a[n], sum=0; for(int i=0; i<n; i++) cin >> a[i], sum += a[i]; long prefix[n]; prefix[0] = a[0]; for(int i=1; i<n; i++) prefix[i] = i + prefix[i-1]; long long ans = 1e9; for(int i = 0; i<n; i++) ans = min(abs(prefix[i] - (sum - prefix[i])), ans); cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:16:37: error: no matching function for call to 'min(long int, long long int&)' 16 | for(int i = 0; i<n; i++) ans = min(abs(prefix[i] - (sum - prefix[i])), ans); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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:16:37: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int') 16 | for(int i = 0; i<n; i++) ans = min(abs(prefix[i] - (sum - prefix[i])), 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: /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:16:37: note: mismatched types 'std::initializer_list<_Tp>' and 'long int' 16 | for(int i = 0; i<n; i++) ans = min(abs(prefix[i] - (sum - prefix[i])), ans); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s316444978
p03659
Java
import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[] a = new long[n]; long[] s = new long[n]; for(int i = 0;i < n;i++)a[i]=sc.nextInt(); for(int i = 0;i < n;i++){ for(int j = 0;j < i;j++)s[i]+=a[j]; } long min = 10000000000; for(int i = 0;i < n-1;i++)min = Math.min(min,Math.abs(s[i+1]-s[i])); System.out.println(min); } }
Main.java:12: error: integer number too large long min = 10000000000; ^ 1 error
s064780104
p03659
C++
n = gets.to_i nums = gets.split.map(&:to_i) cumulative_sums = [] previous = 0 nums.each do |num| cumulative_sums << num + previous previous += num end cumulative_sums_r = [] previous = 0 nums.reverse.each do |num| cumulative_sums_r.unshift(num + previous) previous += num end gaps = [] (1...n).each do |index| gaps << (cumulative_sums[index - 1] - cumulative_sums_r[index]).abs end puts gaps.min
a.cc:19:2: error: too many decimal points in number 19 | (1...n).each do |index| | ^~~~~ a.cc:1:1: error: 'n' does not name a type 1 | n = gets.to_i | ^
s382801177
p03659
C++
#include <isotream> #include <vector> using namespace std; int main(void){ int N; cin >> N; long long int total; vector<long long int> A(N); for(int i = 0; i < N; i++){ cin >> A[i]; total += A[i]; } long long int snuke = 0LL; long long int arai = total; long long int minDiff = 100000000; for(int i = 0; i < N-1; i++){ snuke += A[i]; arai -= A[i]; minDiff = min(abs(snuke - arai),minDiff); } cout << minDiff; }
a.cc:1:10: fatal error: isotream: No such file or directory 1 | #include <isotream> | ^~~~~~~~~~ compilation terminated.
s676861943
p03659
C++
#include <iostream> #include <vector> using namespace std; int main(void){ int N; long long int total = 0LL; vector<long long int> a(N); for(int i = 0; i < N; i++){ cin >> a[i]; total += a[i]; } long long int arai, snuke; snuke = 0LL; arai = total; long long int minDiff = total; for(int = 0; i < N-1; i++){ snuke += a[i]; arai -= a[i]; minDiff = min(abs(snuke - arai), minDiff); } cout << minDiff; }
a.cc: In function 'int main()': a.cc:18:11: error: expected unqualified-id before '=' token 18 | for(int = 0; i < N-1; i++){ | ^ a.cc:18:10: error: expected ';' before '=' token 18 | for(int = 0; i < N-1; i++){ | ^~ | ; a.cc:18:11: error: expected primary-expression before '=' token 18 | for(int = 0; i < N-1; i++){ | ^ a.cc:18:16: error: 'i' was not declared in this scope 18 | for(int = 0; i < N-1; i++){ | ^ a.cc:18:23: error: expected ')' before ';' token 18 | for(int = 0; i < N-1; i++){ | ~ ^ | ) a.cc:18:25: error: 'i' was not declared in this scope 18 | for(int = 0; i < N-1; i++){ | ^
s393153198
p03659
C++
#include <iostream> #include <vector> using namespace std; int main(void){ int N; long long int total = 0LL; vector<long long int> a(N); for(int i = 0; i < N; i++){ cin >> a[i]; total += a[i]; } long long int arai, snuke; snuke = 0LL; arai = total; minDiff = total; for(int = 0; i < N-1; i++){ snuke += a[i]; arai -= a[i]; minDiff = min(abs(snuke - arai), minDiff); } cout << minDiff; }
a.cc: In function 'int main()': a.cc:17:3: error: 'minDiff' was not declared in this scope 17 | minDiff = total; | ^~~~~~~ a.cc:18:11: error: expected unqualified-id before '=' token 18 | for(int = 0; i < N-1; i++){ | ^ a.cc:18:10: error: expected ';' before '=' token 18 | for(int = 0; i < N-1; i++){ | ^~ | ; a.cc:18:11: error: expected primary-expression before '=' token 18 | for(int = 0; i < N-1; i++){ | ^ a.cc:18:16: error: 'i' was not declared in this scope 18 | for(int = 0; i < N-1; i++){ | ^ a.cc:18:23: error: expected ')' before ';' token 18 | for(int = 0; i < N-1; i++){ | ~ ^ | ) a.cc:18:25: error: 'i' was not declared in this scope 18 | for(int = 0; i < N-1; i++){ | ^
s909848692
p03659
C++
#include <isotream> #include <vector> using namespace std; int main(void){ int N; long long int total = 0LL; vector<long long int> a(N); for(int i = 0; i < N; i++){ cin >> a[i]; total += a[i]; } long long int arai, snuke; snuke = 0LL; arai = total; minDiff = total; for(int = 0; i < N-1; i++){ snuke += a[i]; arai -= a[i]; minDiff = min(abs(snuke - arai), minDiff); } cout << minDiff; }
a.cc:1:10: fatal error: isotream: No such file or directory 1 | #include <isotream> | ^~~~~~~~~~ compilation terminated.
s512553789
p03659
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main(){ int N; cin >> N; vector<ll> A(N); for(int i = 0; i <N; i++) cin >> A[i]; int left[N], right[N]; // index iまでの和 left[0] = A[0], right[N-1] = A[N-1]; for(int i = 1; i < N; i++){ left[i] = left[i-1] + A[i]; } ll sum = left[N-1]; ll ans = 1000000000000000000LL; for(int i = 0; i < N - 1; i++){ ans = min(ans, abs(2 * left[i] - sum)); } /* for(int i = N - 2; i >= 0; i--){ right[i] = right[i+1] + A[i]; } //for(int i = 0; i < N; i++) cout << right[i] << endl; ll minsum = 1e18; for(int i = 1; i < N; i++){ minsum = min(minsum, llabs(left[i-1] - right[i])); }*/ cout << minsum << endl; }
a.cc: In function 'int main()': a.cc:29:13: error: 'minsum' was not declared in this scope 29 | cout << minsum << endl; | ^~~~~~
s095891438
p03659
C++
#include <iostream> #include <vector> using namespace std; int main(){ int N; cin >> N; long long int sunuke = 0; vector<long long int> a(N); for(int i = 0; i < N; i++){ long long int t; cin >> t; sunuke += t; N[i] = t; } long long int arai = 0; long long int ans = 200000; for(int i = N-1; i > 0; i--){ arai += V[i]; sunuke -= V[i]; ans = min(abs(sunuke - arai),ans); } cout << ans; }
a.cc: In function 'int main()': a.cc:16:6: error: invalid types 'int[int]' for array subscript 16 | N[i] = t; | ^ a.cc:22:13: error: 'V' was not declared in this scope 22 | arai += V[i]; | ^
s317561993
p03659
C++
#include <iostream> #include <vecotr> using namespace std; int main(){ int N; cin >> N; long long int sunuke = 0; vector<long long int> a(N); for(int i = 0; i < N; i++){ long long int t; cin >> t; sunuke += t; N[i] = t; } long long int arai = 0; long long int ans = 200000; for(int i = N-1; i > 0; i--){ arai += V[i]; sunuke -= V[i]; ans = min(abs(sunuke - arai),ans); } cout << ans; }
a.cc:2:10: fatal error: vecotr: No such file or directory 2 | #include <vecotr> | ^~~~~~~~ compilation terminated.
s437652496
p03659
C++
#include <iostream> #include <vecotr>; using namespace std; int main(){ int N; cin >> N; long long int sunuke = 0; vector<long long int> a(N); for(int i = 0; i < N; i++){ long long int t; cin >> t; sunuke += t; N[i] = t; } long long int arai = 0; long long int ans = 200000; for(int i = N-1; i > 0; i--){ arai += V[i]; sunuke -= V[i]; ans = min(abs(sunuke - arai),ans); } cout << ans; }
a.cc:2:18: warning: extra tokens at end of #include directive 2 | #include <vecotr>; | ^ a.cc:2:10: fatal error: vecotr: No such file or directory 2 | #include <vecotr>; | ^~~~~~~~ compilation terminated.
s950006164
p03659
C++
#include<bits/stdc++.h> #include <boost/multiprecision/cpp_dec_float.hpp> #include <boost/multiprecision/cpp_int.hpp> #include <boost/numeric/interval.hpp> #include <boost/numeric/interval/io.hpp> using namespace::std; namespace mp = boost::multiprecision; typedef mp::number<mp::cpp_dec_float<32,int64_t>> cfloat; typedef mp::cpp_int cint; typedef long long lint; typedef long long ll; typedef long double ldouble; typedef vector<lint> vec; typedef vector<vector<lint>> mat; typedef vector<vector<vector<lint>>> mat3; typedef vector<double> dvec; typedef vector<vector<double>> dmat; typedef vector<vector<vector<double>>> dmat3; typedef vector<string> svec; typedef vector<vector<string>> smat; typedef vector<vector<vector<string>>> smat3; #define rep(i, n) for(lint i = 0; i < (lint)(n); i++) #define irep(i) for(lint i = 0;; i++) #define irep1(i) for(lint i = 1;; i++) #define irep2(i) for(lint i = 2;; i++) #define rrep(i, n) for(lint i = (lint)(n-1); i >-1; i--) #define rrepi(i,a,b) for(lint i = (lint)(b-1); i >a-1; i--) #define repi(i,a,b) for(lint i=lint(a);i<lint(b);i++) #define rep2(i,a,b,c) for(lint i=lint(a);i>lint(b);i+=c) #define all(x) (x).begin(),(x).end() #define sl(c) (('a')<=(c)&&(c)<=('z')) #define ll(c) (('A')<=(c)&&(c)<=('Z')) #define max3(a,b,c) max(a,max(b,c)) #define min3(a,b,c) min(a,min(b,c)) #define PI 3.141592653589793 #define cout (cout<<fixed<<setprecision(15)) #define makeupper(t) (transform(all(t),t.begin(),::toupper)) #define makelower(t) (transform(all(t),t.begin(),::tolower)) #define dist(x1,y1,x2,y2) (pow(pow(x2-x1,2)+pow(y2-y1,2),0.5)) #define NEXT_LINE string junk; getline(cin, junk); #define output(v) do{rep(i,v.size())cout<<(i?" ":"")<<v[i];cout<<"\n";}while(0) #define output2(v) rep(i,v.size()){rep(j,v[i].size()){cout<<(j?" ":"")<<v[i][j];}cout<<"\n";} #define input(a,n) lint n;cin>>n;vector<lint>a(n);rep(i,n)cin>>a[i]; #define INF (1LL<<60) #define IINF (1<<30) #define LINF 9223372036854775807 #define MOD 1000000007 vector<lint> dx={-1,1,0,0,1,1,-1,-1}; vector<lint> dy={0,0,-1,1,1,-1,1,-1}; inline lint gcd(lint a,lint b){return b?gcd(b,a%b):a;} inline lint lcm(lint a,lint b){return a*b/gcd(a,b);} vector<lint> operator+(const vector<lint>& v1,const vector<lint>& v2){ vector<lint> v(v1.size()+v2.size(),0); rep(i,v1.size())v[i]=v1[i]; rep(i,v2.size())v[i+v1.size()]=v2[i]; return v; } inline lint sum(vector<lint> v){ lint sum=0; rep(i,v.size())sum+=v[i]; return sum; } inline vector<int> cross(vector<int> a, vector<int> b) { return { a[1] * b[2] - a[2] * b[1],a[2] * b[0] - a[0] * b[2],a[0] * b[1] - a[1] * b[0] }; } inline vector<lint> primeList(lint n) { vector<bool> p(n+1); vector<lint> list; repi(i,1, n+1)p[i] = true; repi(i,2,sqrt(n)+1) { if (p[i]) { repi(j,2,n/i+1) { p[i*j] = false; } } } repi(i, 2, n+1)if (p[i])list.push_back(i); return list; } inline set<lint> primeSet(lint n) { vector<bool> p(n+1); set<lint> set; repi(i,1, n+1)p[i] = true; repi(i,2,sqrt(n)+1) { if (p[i]) { repi(j,2,n/i+1) { p[i*j] = false; } } } repi(i, 2, n+1)if (p[i])set.insert(i); return set; } inline bool isPrime(int num){ if (num < 2) return false; else if (num == 2) return true; else if (num % 2 == 0) return false; double sqrtNum = sqrt(num); for (int i = 3; i <= sqrtNum; i += 2){ if (num % i == 0)return false; } return true; } inline lint max(vector<lint> num){ lint M=num[0]; rep(i,num.size())M=max(M,num[i]); return M; } inline lint min(vector<lint> num){ lint M=num[0]; rep(i,num.size())M=min(M,num[i]); return M; } inline cint cmax(vector<cint> num){ cint M=num[0]; rep(i,num.size())if(M<num[i])M=num[i]; return M; } inline cint cmin(vector<cint> num){ cint M=num[0]; rep(i,num.size())if(M>num[i])M=num[i]; return M; } inline lint signal(lint val){ if(val==0)return 0; else return val/abs(val); } struct IVector2{ lint x,y; }; bool operator< (const IVector2 &s, const IVector2 &t){ return s.x==t.x?s.y<t.y:s.x<t.x; }; bool operator> (const IVector2 &s, const IVector2 &t){ return s.x==t.x?s.y>t.y:s.x>t.x; }; struct IVector3{ lint x,y,z; }; struct IVector4{ lint x,y,z,w; }; template<typename... args>struct dfs{ public: queue<function<void(void)>> que; function<void(args...,dfs<args...>&)> func; void run(){ while(!que.empty()){ que.front()(); que.pop(); } } void push(args... arg){ que.push(bind(func,arg...,ref(*this))); } dfs(args... init,function<void(args...,dfs<args...>&)> func):func(func){ push(init...); run(); } }; lint mod_pow(lint x,lint y,lint mod){ if(y==0)return 1; else if(y==1)return x; else if(y%2==1)return x*mod_pow(x,y-1,mod)%mod; else return mod_pow(x,y/2,mod)*mod_pow(x,y/2,mod)%mod; } lint binary_search(function<bool(lint)> func) { lint left = -1; lint right =IINF; while (right - left > 1) { lint mid = left + (right - left) / 2; if (func(mid)) right = mid; else left = mid; } return right; } int main(){ lint n; cin>>n; vector<cint> a(n); rep(i,n)cin>>a[i]; vector<cint> b(a); repi(i,1,n)b[i]+=b[i-1]; cint m=LINF; cint s=0; rep(i,n){ s+=a[i]; } rep(i,n-1)m=min(m,abs(b[i]*2-s)); cout<<m; }
a.cc:2:10: fatal error: boost/multiprecision/cpp_dec_float.hpp: No such file or directory 2 | #include <boost/multiprecision/cpp_dec_float.hpp> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ compilation terminated.
s276923730
p03659
C++
#include <bits/stdc++.h> #define REP(i, n) for(ll i = 0; i < (ll)n; i++) #define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++) #define ALL(obj) (obj).begin(), (obj).end() #define INF (1ll << 60) using namespace std; typedef long long ll; typedef double db; typedef string str; typedef pair<ll, ll> p; constexpr int MOD = 1000000007; using ll = long long; template <class T> inline bool chmin(T &a, T b) { if(a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } void print(const std::vector<int> &v) { std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; }); std::cout << std::endl; } int main() { long long N; cin >> N; vector<long long> a(N); REP(i, N) { cin >> a[i]; } long long s = accumulate(a.begin(), a.end(), 0); long long sum = 0; long long res = INF; for(int i = 0; i < N; i++) { sum += a[i]; res = min(res, abs(s - 2 * sum)) } cout << res << endl; return 0; }
a.cc: In function 'int main()': a.cc:43:41: error: expected ';' before '}' token 43 | res = min(res, abs(s - 2 * sum)) | ^ | ; 44 | } | ~
s660224075
p03659
C++
#include <bits/stdc++.h> #define REP(i, n) for(ll i = 0; i < (ll)n; i++) #define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++) #define ALL(obj) (obj).begin(), (obj).end() #define INF (1ll << 60) using namespace std; typedef long long ll; typedef double db; typedef string str; typedef pair<ll, ll> p; constexpr int MOD = 1000000007; using ll = long long; template <class T> inline bool chmin(T &a, T b) { if(a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } void print(const std::vector<int> &v) { std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; }); std::cout << std::endl; } int main() { long long N; cin >> N; vector<long long> a(N); REP(i, N) { cin >> a[i]; } long long s = accumulate(a.begin(), a.end(), 0); long long sum = 0; long long res = INF; for(int i = 0; i < N; i++) { sum += a[i]; res = min(res, abs(S - 2 * x)) } cout << res << endl; return 0; }
a.cc: In function 'int main()': a.cc:43:28: error: 'S' was not declared in this scope 43 | res = min(res, abs(S - 2 * x)) | ^ a.cc:43:36: error: 'x' was not declared in this scope 43 | res = min(res, abs(S - 2 * x)) | ^
s315551828
p03659
C++
#include <bits/stdc++.h> #define REP(i, n) for(ll i = 0; i < (ll)n; i++) #define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++) #define ALL(obj) (obj).begin(), (obj).end() #define INF (1ll << 60) using namespace std; typedef long long ll; typedef double db; typedef string str; typedef pair<ll, ll> p; constexpr int MOD = 1000000007; using ll = long long; template <class T> inline bool chmin(T &a, T b) { if(a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if(a < b) { a = b; return true; } return false; } void print(const std::vector<int> &v) { std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; }); std::cout << std::endl; } int main() { long long N; cin >> N; vector<long long> a(N); REP(i, N) { cin >> a[i]; } long long s = accumulate(a.begin(), a.end(), 0); long long sum = 0; long long sum = INF; for(int i = 0; i < N; i++) { sum += a[i]; res = min(res, abs(S - 2 * x)) } cout << res << endl; return 0; }
a.cc: In function 'int main()': a.cc:40:15: error: redeclaration of 'long long int sum' 40 | long long sum = INF; | ^~~ a.cc:39:15: note: 'long long int sum' previously declared here 39 | long long sum = 0; | ^~~ a.cc:43:9: error: 'res' was not declared in this scope 43 | res = min(res, abs(S - 2 * x)) | ^~~ a.cc:43:28: error: 'S' was not declared in this scope 43 | res = min(res, abs(S - 2 * x)) | ^ a.cc:43:36: error: 'x' was not declared in this scope 43 | res = min(res, abs(S - 2 * x)) | ^ a.cc:45:13: error: 'res' was not declared in this scope 45 | cout << res << endl; | ^~~
s689434404
p03659
C++
// template #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<long long, long long> LP; #define INF 999999999 #define MOD 1000000007 #define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i) #define REP_AB(i, a, b) for (int i = int(a); i <= int(b); ++i) #define ALL(v) v.begin(), v.end() #define SORT(v) sort(ALL(v)) #define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end()); #define SIZE(x) ((ll)(x).size()) ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;} int dx[4]={1,0,-1,0}; int dy[4]={0,1,0,-1}; #define out cout #define in cin 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 end int main() { ios::sync_with_stdio(false); cin.tie(0); ll n; in >> n; vector<ll> a(n); ll a_tmp; in >> a[0]; REP(i, n-1){ in >> a_tmp; a[i+1] = a[i] + a_tmp; } ll a_max = a[n-1]; ll ans = 1e10; REP(i, n-1){ ans = min(ans, abs(a_max - a[i], a[i])); } out << ans << endl; }
a.cc: In function 'int main()': a.cc:41:27: error: no matching function for call to 'abs(ll, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)' 41 | ans = min(ans, abs(a_max - a[i], a[i])); | ~~~^~~~~~~~~~~~~~~~~~~~ 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:2: /usr/include/c++/14/bits/valarray_after.h:445:5: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_UnClos<std::_Abs, std::_ValArray, _Tp>, _Tp> std::abs(const valarray<_Tp>&)' 445 | _DEFINE_EXPR_UNARY_FUNCTION(abs, struct std::_Abs) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:445:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/valarray_after.h:445:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_UnClos<std::_Abs, std::_Expr, _Dom>, typename _Dom::value_type> std::abs(const _Expr<_Dom1, typename _Dom1::value_type>&)' 445 | _DEFINE_EXPR_UNARY_FUNCTION(abs, struct std::_Abs) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:445:5: note: candidate expects 1 argument, 2 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:892:5: note: candidate: 'template<class _Tp> _Tp std::abs(const complex<_Tp>&)' 892 | abs(const complex<_Tp>& __z) { return __complex_abs(__z.__rep()); } | ^~~ /usr/include/c++/14/complex:892:5: note: candidate expects 1 argument, 2 provided In file included from /usr/include/c++/14/cstdlib:79, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42: /usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)' 980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~ /usr/include/stdlib.h:980:12: note: candidate expects 1 argument, 2 provided In file included from /usr/include/c++/14/cstdlib:81: /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)' 137 | abs(__float128 __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)' 85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)' 79 | abs(long double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)' 75 | abs(float __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)' 71 | abs(double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)' 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)' 56 | abs(long __i) { return __builtin_labs(__i); } | ^~~ /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate expects 1 argument, 2 provided
s355119810
p03659
C++
// template #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<long long, long long> LP; #define INF 999999999 #define MOD 1000000007 #define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i) #define REP_AB(i, a, b) for (int i = int(a); i <= int(b); ++i) #define ALL(v) v.begin(), v.end() #define SORT(v) sort(ALL(v)) #define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end()); #define SIZE(x) ((ll)(x).size()) ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;} int dx[4]={1,0,-1,0}; int dy[4]={0,1,0,-1}; #define out cout #define in cin 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 end int main() { ios::sync_with_stdio(false); cin.tie(0); ll n; in >> n; vector<ll> a(n); ll a_tmp; in >> a[0]; REP(i, n-1){ in >> a_tmp; a[i+1] = a[i] + a_tmp; } ll a_max = a[n-1]; ll ans = 1e10; REP(i, n){ ans = min(ans, abs(a_max - a[i], a[i])); } out << ans << endl; }
a.cc: In function 'int main()': a.cc:41:27: error: no matching function for call to 'abs(ll, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)' 41 | ans = min(ans, abs(a_max - a[i], a[i])); | ~~~^~~~~~~~~~~~~~~~~~~~ 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:2: /usr/include/c++/14/bits/valarray_after.h:445:5: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_UnClos<std::_Abs, std::_ValArray, _Tp>, _Tp> std::abs(const valarray<_Tp>&)' 445 | _DEFINE_EXPR_UNARY_FUNCTION(abs, struct std::_Abs) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:445:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/valarray_after.h:445:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_UnClos<std::_Abs, std::_Expr, _Dom>, typename _Dom::value_type> std::abs(const _Expr<_Dom1, typename _Dom1::value_type>&)' 445 | _DEFINE_EXPR_UNARY_FUNCTION(abs, struct std::_Abs) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:445:5: note: candidate expects 1 argument, 2 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:892:5: note: candidate: 'template<class _Tp> _Tp std::abs(const complex<_Tp>&)' 892 | abs(const complex<_Tp>& __z) { return __complex_abs(__z.__rep()); } | ^~~ /usr/include/c++/14/complex:892:5: note: candidate expects 1 argument, 2 provided In file included from /usr/include/c++/14/cstdlib:79, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42: /usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)' 980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~ /usr/include/stdlib.h:980:12: note: candidate expects 1 argument, 2 provided In file included from /usr/include/c++/14/cstdlib:81: /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)' 137 | abs(__float128 __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)' 85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)' 79 | abs(long double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)' 75 | abs(float __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)' 71 | abs(double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)' 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)' 56 | abs(long __i) { return __builtin_labs(__i); } | ^~~ /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate expects 1 argument, 2 provided
s194068395
p03659
C++
// template #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<long long, long long> LP; #define INF 999999999 #define MOD 1000000007 #define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i) #define REP_AB(i, a, b) for (int i = int(a); i <= int(b); ++i) #define ALL(v) v.begin(), v.end() #define SORT(v) sort(ALL(v)) #define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end()); #define SIZE(x) ((ll)(x).size()) ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;} int dx[4]={1,0,-1,0}; int dy[4]={0,1,0,-1}; #define out cout #define in cin 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 end int main() { ios::sync_with_stdio(false); cin.tie(0); ll n; in >> n; vector<ll> a(n); ll a_tmp; in >> a[0]; REP(i, n-1){ in >> a_tmp; a[i+1] = a[i] + a_tmp; } ll a_max = a[n-1]; ll ans = 1e10; REP(i, n){ ans = min(ans, abs(max - a[i], a[i])); } out << ans << endl; }
a.cc: In function 'int main()': a.cc:41:32: error: invalid operands of types '<unresolved overloaded function type>' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to binary 'operator-' 41 | ans = min(ans, abs(max - a[i], a[i]));
s272910693
p03659
C++
// template #include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<long long, long long> LP; #define INF 999999999 #define MOD 1000000007 #define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i) #define REP_AB(i, a, b) for (int i = int(a); i <= int(b); ++i) #define ALL(v) v.begin(), v.end() #define SORT(v) sort(ALL(v)) #define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end()); #define SIZE(x) ((ll)(x).size()) ll gcd(ll a,ll b){return b?gcd(b,a%b):a;} ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;} int dx[4]={1,0,-1,0}; int dy[4]={0,1,0,-1}; #define out cout #define in cin 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 end int main() { ios::sync_with_stdio(false); cin.tie(0); ll n; in >> n; vector<ll> a(n); ll a_tmp; in >> a[0]; REP(i, n-1){ in >> a_tmp; a[i+1] = a[i] + a_tmp; } a_max = a[n-1] ll ans = 1e10; REP(i, n){ ans = min(ans, abs(max - a[i], a[i])) } out << ans << endl; }
a.cc: In function 'int main()': a.cc:38:5: error: 'a_max' was not declared in this scope 38 | a_max = a[n-1] | ^~~~~ a.cc:41:9: error: 'ans' was not declared in this scope; did you mean 'abs'? 41 | ans = min(ans, abs(max - a[i], a[i])) | ^~~ | abs a.cc:41:32: error: invalid operands of types '<unresolved overloaded function type>' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to binary 'operator-' 41 | ans = min(ans, abs(max - a[i], a[i])) a.cc:43:12: error: 'ans' was not declared in this scope; did you mean 'abs'? 43 | out << ans << endl; | ^~~ | abs
s765446358
p03659
C++
#include <iostream> using namespace std; int main(){ int n;cin>>n; long long a[n]; for(int i = 0; n > i; i++){ cin>>a[i]; } long long b[n]; b[0]=0; for(int i = 1; n-1 > i; i++){ b[i]=a[i]+b[i-1]; } int ans = abs((a[n]+b[n-1]-b[1])-(a[0]+b[1]))); for(int i = 1; n-1 > i; i++){ ans = min(ans,abs((a[n]+b[n-1]-b[i])-(a[0]+b[i]))); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:14:48: error: expected ',' or ';' before ')' token 14 | int ans = abs((a[n]+b[n-1]-b[1])-(a[0]+b[1]))); | ^ a.cc:16:14: error: no matching function for call to 'min(int&, long long int)' 16 | ans = min(ans,abs((a[n]+b[n-1]-b[i])-(a[0]+b[i]))); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 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:16:14: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 16 | ans = min(ans,abs((a[n]+b[n-1]-b[i])-(a[0]+b[i]))); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /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
s201116703
p03659
C++
#include <iostream> using namespace std; int main(){ int n;cin>>n; long long a[n]; long long mn = 0 for(int i = 0; n > i; i++){ cin>>a[i]; mn = min(mn,a[i]); } long long b[n+1]; b[0]=0; for(int i = 0; n > i; i++){ b[i+1] = b[i]+a[i]+(mn*-1); } long long ans = b[n]; for(int i = 1;n > i; i++){ ans = min(ans,b[n]-(b[n]-b[i])); } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:7:3: error: expected ',' or ';' before 'for' 7 | for(int i = 0; n > i; i++){ | ^~~ a.cc:7:22: error: 'i' was not declared in this scope 7 | for(int i = 0; n > i; i++){ | ^
s950107823
p03659
C++
#include <bits/stdc++.h> using namespace std; #define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i) #define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i) #define per(i,N) for(int i=(N)-1;i>=0;--i) #define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i) #define all(arr) (arr).begin(), (arr).end() #define SP << " " << #define SPF << " " #define SPEEDUP cin.tie(0);ios::sync_with_stdio(false); #define MAX_I INT_MAX //1e9 #define MIN_I INT_MIN //-1e9 #define MAX_UI UINT_MAX //1e9 #define MAX_LL LLONG_MAX //1e18 #define MIN_LL LLONG_MIN //-1e18 #define MAX_ULL ULLONG_MAX //1e19 typedef long long ll; typedef pair<int,int> PII; typedef pair<char,char> PCC; typedef pair<ll,ll> PLL; typedef pair<char,int> PCI; typedef pair<int,char> PIC; typedef pair<ll,int> PLI; typedef pair<int,ll> PIL; typedef pair<ll,char> PLC; typedef pair<char,ll> PCL; inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;} inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;} inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;} int main(void){ SPEEDUP cout << setprecision(15); int N;cin >> N; vector<ll> v(N); rep(i,N){ int x; cin >> x; v[i] = x; if(i!=0)v[i]+=v[i-1]; } int mi = MAX_I; rep(i,N-1){ mi = min(mi,abs(2*v[i] - v[i+1])); } cout << mi << endl; return 0; }
a.cc: In function 'int main()': a.cc:45:13: error: no matching function for call to 'min(int&, long long int)' 45 | mi = min(mi,abs(2*v[i] - v[i+1])); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~ 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:45:13: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 45 | mi = min(mi,abs(2*v[i] - v[i+1])); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /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:45:13: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 45 | mi = min(mi,abs(2*v[i] - v[i+1])); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
s653730784
p03659
C
#include <stdio.h> #define abs(x) ((x) > 0 ? (x) : -(x)) #define min(x, y) ((x) > (y) ? (x) : (y)) int main(int argc, char *argv[]) { int n, a[200000]; long long int sum = 0, sum2 = 0; scanf("%d", &n); for(int i = 0; i < n; i++){ scanf("%d", &a[i]); sum += (long long)a[i]; } long long ans = abs(2*(long long)a[0] - sum); for(int i = 0; i < n; i++){ sum2 += (long long)a[i]; sum -= (long long)a[i]; ans = min(ans, sum - sum2)); } printf("%lld\n", ans); return 0; }
main.c: In function 'main': main.c:19:31: error: expected ';' before ')' token 19 | ans = min(ans, sum - sum2)); | ^ main.c:19:31: error: expected statement before ')' token
s523257617
p03659
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin>>n; long long a[n],sum=0,snuke=0; for(int i=0;i<n;i++){ cin>>a[i]; sum+=a[i]; } for(int i=0;i<n;i++){ snuke+=a[i]; if(snuke>=sum/2&&snuke-a[i]<=sum/2){ cout<<sum-2*snuke;<<endl; return 0; } } }
a.cc: In function 'int main()': a.cc:14:25: error: expected primary-expression before '<<' token 14 | cout<<sum-2*snuke;<<endl; | ^~
s264680220
p03659
C++
#include <bits/stc++.h> #include <stdio.h> using namespace std; int main(void) { long n; cin >> n; vector<long long> vec; for (int i = 0; i < n; i++) { int num; scanf("%d", &num); vec.push_back(num); } long long total = 0; for (int i = 0; i < vec.size(); i++) { total += vec.at(i); } long long ave = total / 2; long long min_diff = 1000000000; long long nusuke = 0; long long value = 0; for (int i = 0; i < vec.size() - 1; i++) { nusuke += vec.at(i); long long diff = ave - nusuke; if (diff < 0) diff = diff * -1; if (min_diff > diff) { value = nusuke; min_diff = diff; } /* cout << "loop: " << i << endl; cout << "nusuke: " << nusuke << endl; cout << "arai: " << total - nusuke << endl; cout << "diff: " << diff << endl; cout << "min_diff: " << min_diff << endl; */ } long long diff = value - (total - value); if (diff < 0) diff = diff * -1; cout << diff << endl; return 0; }
a.cc:1:10: fatal error: bits/stc++.h: No such file or directory 1 | #include <bits/stc++.h> | ^~~~~~~~~~~~~~ compilation terminated.
s474727399
p03659
C++
#include<iostream> #include<vector> #include<numeric> using namespace std; using ll = long long int; int n; vector<ll> a; ll suml = 0, sumr = 0; ll ret = LLONG_MAX; int main(void) { cin >> n; for (size_t i = 0; i < n; i++){ ll ai; cin >> ai; a.push_back(ai); sumr += ai; } for (int i = 0; i < n - 1; i++) { suml += a[i]; sumr -= a[i]; ll tmp = abs(suml - sumr); if (tmp < ret) { ret = tmp; } } cout << ret << endl; return 0; }
a.cc:9:10: error: 'LLONG_MAX' was not declared in this scope 9 | ll ret = LLONG_MAX; | ^~~~~~~~~ a.cc:4:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 3 | #include<numeric> +++ |+#include <climits> 4 | using namespace std;
s131929103
p03659
C++
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (n); ++i) #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define print(s) cout << s << endl #define acc(v) accumulate(v.begin(), v.end(), 0) #define cinv(n,v) rep(i,n) cin >> v[i] using namespace std; const int INF = 1e9; typedef long long ll; typedef vector<int> vint; typedef vector<string> vstr; typedef vector<char> vchar; const ll LINF = 1e18; const ll MOD = 1e9 + 7; // const lint MOD = 998244353; int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1}; int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; } char upper(char c){ return c-0x20; } char lower(char c){ return c+0x20; } ll gcd(ll x, ll y) { if (y == 0) return x; return gcd(y, x%y); } ll lcm(ll x, ll y){ ll g = gcd(x,y); return x/g*y; } int main(){ int n; cin>>n; ll s = 0; vector<ll> v(n), vv(n); ll X=0,x=0; rep(i,n){ cin >> v[i]; X += v[i]; } ll m = MOD; for (int i = 0; i < n-1; i++){ x += a[i]; m = min(m,abs(x*2 - X)); } cout << m << endl; }
a.cc: In function 'int main()': a.cc:52:22: error: 'a' was not declared in this scope 52 | x += a[i]; | ^
s459254516
p03659
C++
#include <bits/stdc++.h> using namespace std; const long long int MOD=1e9+7; int main() { int n,k; cin>>n>>k; int arr[n]; int sum=0; for(int i=0;i<n;i++){ cin>>arr[i]; sum+=arr[i]; } int cur=0; int mn=INT_MAX; for(int i=0;i<n;i++){ cur+=arr[i]; mn=min(mn,abs(sum-2*cur)) } cout<<mn; }
a.cc: In function 'int main()': a.cc:17:42: error: expected ';' before '}' token 17 | mn=min(mn,abs(sum-2*cur)) | ^ | ; 18 | } | ~
s311527592
p03659
C++
#include <iostream> #include <vector> #include <algorithm> #include <cmath> using namespace std; int main(void){ int N; cin >> N; vector<long>num(N,0); for(int i=0;i<N;i++){ cin >> num[i]; } for(int i=1;i<N;i++){ num[i] = num[i] + num[i - 1]; } long sum = num[N - 1] / 2; long gap = 9999999999; int c = 0; for(int i=0;i<N;i++){ if(gap > abs(sum - num[i])){ gap = abs(sum - num[i]); c = i; } } cout << abs(num[N - 1] - num[i]) << endl; return 0; }
a.cc: In function 'int main()': a.cc:30:32: error: 'i' was not declared in this scope 30 | cout << abs(num[N - 1] - num[i]) << endl; | ^
s651554602
p03659
C++
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<int> a(n); vector<int> b(n-1) for(int i=0;i<n;i++){ cin >> a.at(i); } long x=0; long y=0; for(int i=0;i<n-1;i++){ for(int j=0;j<=i;j++){ x += a.at(j); } for(int k=i+1;k<n;k++){ y += a.at(k); } b.at(i) = max(x-y,y-x); } 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++){ | ^
s901903399
p03659
C++
#ifdef _DEBUG #include "MyLib.h" #else #define main_C main #include "bits/stdc++.h" #include <regex> #define _USE_MATH_DEFINES #include <math.h> #define FOR(i,s,e) for (int i = int(s); i < int(e); ++i) #define REP(i,e) FOR(i,0,e) //#define INF (INT_MAX/2) #define EPS (1.0e-8) //#define LINF (LLONG_MAX/2) const int MGN = 8; const int ARY_SZ_MAX = 10000000; using namespace std; using ll = long long; using ull = unsigned long long; using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>; using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>; using vl = vector<ll>; using vvl = vector<vl>; using vd = vector<double>; using vs = vector<string>; using pii = pair<int, int>; using pll = pair<ll, ll>; using psi = pair<string, int>; // functions #endif int main_C() { std::cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; vl A(N); REP(i, N) cin >> A[i]; vl sum(N, 0); sum[0] = A[0]; FOR(i,1,N) { sum[i] = sum[i - 1] + A[i]; } ll ans = LINF; if (N==2) { ll x = A[0]; ll y = A[1]; ans = abs(x - y); } else { FOR(i,1,N-1) { ll x = sum[i]; ll y = sum[N - 1] - x; ans = min(ans, abs(x - y)); } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:42:14: error: 'LINF' was not declared in this scope 42 | ll ans = LINF; | ^~~~
s568161141
p03659
Java
import java.util.*; public class ABC067{ public static void main(String args[]){ // スキャナーの宣言 Scanner sc = new Scanner(System.in); // 整数の入力 int n = sc.nextInt(); long[] a = new long[n]; for(int i = 0; i < n; i++){ a[i] = sc.nextInt(); } int i = 1, j = 1; long x = a[0], y = a[n-1]; while(i + j != n){ if(Math.abs(x + a[i] - y) <= Math.abs(x - (y + a[n-1-j]))){ x += a[i]; i++; }else{ y += a[n-1-j]; j++; } } // 出力 System.out.println(Math.abs(x-y)); } }
Main.java:3: error: class ABC067 is public, should be declared in a file named ABC067.java public class ABC067{ ^ 1 error
s717545501
p03659
Java
Import java.util.*; public class ABC067{ public static void main(String args[]){ // スキャナーの宣言 Scanner sc = new Scanner(System.in); // 整数の入力 int n = sc.nextInt(); long[] a = new long[n]; for(int i = 0; i < n; i++){ a[i] = sc.nextInt(); } int i = 1, j = 1; long x = a[0], y = a[n-1]; while(i + j != n){ if(Math.abs(x + a[i] - y) <= Math.abs(x - (y + a[n-1-j]))){ x += a[i]; i++; }else{ y += a[n-1-j]; j++; } } // 出力 System.out.println(Math.abs(x-y)); } }
Main.java:1: error: class, interface, enum, or record expected Import java.util.*; ^ 1 error
s260414551
p03659
Java
mport java.util.*; public class Main{ public static void main(String args[]){ // スキャナーの宣言 Scanner sc = new Scanner(System.in); // 整数の入力 int n = sc.nextInt(); long[] a = new long[n]; for(int i = 0; i < n; i++){ a[i] = sc.nextInt(); } int i = 1, j = 1; long x = a[0], y = a[n-1]; while(i + j != n){ if(Math.abs(x + a[i] - y) <= Math.abs(x - (y + a[n-1-j]))){ x += a[i]; i++; }else{ y += a[n-1-j]; j++; } } // 出力 System.out.println(Math.abs(x-y)); } }
Main.java:1: error: class, interface, enum, or record expected mport java.util.*; ^ 1 error
s688679400
p03659
C++
#include <bits/stdc++.h> using namespace std; int main() { int n, i, snuke = 0; b = 0, sum = 0, ans = 0, ans2 = 0; cin >> n; vector<int> a(n); for(i = 0; i < n; i++){ cin >> a.at(i); sum += a.at(i); } i = 0; while(snuke < sum / 2){ snuke += a.at(i); i++; } ans = abs(n - 2 * snuke); b = snuke - a.at(i - 1); ans2 = abs(n - 2 * b); cout << min(ans, ans2) << endl; }
a.cc: In function 'int main()': a.cc:5:24: error: 'b' was not declared in this scope 5 | int n, i, snuke = 0; b = 0, sum = 0, ans = 0, ans2 = 0; | ^ a.cc:5:31: error: 'sum' was not declared in this scope 5 | int n, i, snuke = 0; b = 0, sum = 0, ans = 0, ans2 = 0; | ^~~ a.cc:5:40: error: 'ans' was not declared in this scope; did you mean 'abs'? 5 | int n, i, snuke = 0; b = 0, sum = 0, ans = 0, ans2 = 0; | ^~~ | abs a.cc:5:49: error: 'ans2' was not declared in this scope 5 | int n, i, snuke = 0; b = 0, sum = 0, ans = 0, ans2 = 0; | ^~~~
s958169554
p03659
C++
#include <bits/stdc++.h> using namespace std; int main() { int n, i, snuke = 0; s2 = 0, sum = 0, ans = 0, ans2 = 0; cin >> n; vector<int> a(n); for(i = 0; i < n; i++){ cin >> a.at(i); sum += a.at(i); } i = 0; while(snuke < sum / 2){ snuke += a.at(i); i++; } ans = abs(n - 2 * snuke); s2 = snuke - a.at(i - 1); ans2 = abs(n - 2 * s2); cout << min(ans, ans2) << endl; }
a.cc: In function 'int main()': a.cc:5:24: error: 's2' was not declared in this scope 5 | int n, i, snuke = 0; s2 = 0, sum = 0, ans = 0, ans2 = 0; | ^~ a.cc:5:32: error: 'sum' was not declared in this scope 5 | int n, i, snuke = 0; s2 = 0, sum = 0, ans = 0, ans2 = 0; | ^~~ a.cc:5:41: error: 'ans' was not declared in this scope; did you mean 'abs'? 5 | int n, i, snuke = 0; s2 = 0, sum = 0, ans = 0, ans2 = 0; | ^~~ | abs a.cc:5:50: error: 'ans2' was not declared in this scope 5 | int n, i, snuke = 0; s2 = 0, sum = 0, ans = 0, ans2 = 0; | ^~~~
s049102635
p03659
C++
#include <bits/stdc++.h> using namespace std; int main() { int n, i, snuke = 0; snuke_2 = 0, sum = 0, ans = 0, ans_2 = 0; cin >> n; vector<int> a(n); for(i = 0; i < n; i++){ cin >> a.at(i); sum += a.at(i); } i = 0; while(snuke < sum / 2){ snuke += a.at(i); i++; } ans = abs(n - 2 * snuke); snuke_2 = snuke - a.at(i - 1); ans_2 = abs(n - 2 * snuke_2); cout << min(ans, ans_2) << endl; }
a.cc: In function 'int main()': a.cc:5:24: error: 'snuke_2' was not declared in this scope; did you mean 'snuke'? 5 | int n, i, snuke = 0; snuke_2 = 0, sum = 0, ans = 0, ans_2 = 0; | ^~~~~~~ | snuke a.cc:5:37: error: 'sum' was not declared in this scope 5 | int n, i, snuke = 0; snuke_2 = 0, sum = 0, ans = 0, ans_2 = 0; | ^~~ a.cc:5:46: error: 'ans' was not declared in this scope; did you mean 'abs'? 5 | int n, i, snuke = 0; snuke_2 = 0, sum = 0, ans = 0, ans_2 = 0; | ^~~ | abs a.cc:5:55: error: 'ans_2' was not declared in this scope 5 | int n, i, snuke = 0; snuke_2 = 0, sum = 0, ans = 0, ans_2 = 0; | ^~~~~
s565941734
p03659
C++
#include <bits/stdc++.h> using namespace std; int main() { int n, i, snuke = 0; snuke2 = 0, sum = 0, ans = 0, ans2 = 0; cin >> n; vector<int> a(n); for(i = 0; i < n; i++){ cin >> a.at(i); sum += a.at(i); } i = 0; while(snuke < sum / 2){ snuke += a.at(i); i++; } ans = abs(n - 2 * snuke); snuke2 = snuke - a.at(i - 1); ans2 = abs(n - 2 * snuke2); cout << min(ans, ans2) << endl; }
a.cc: In function 'int main()': a.cc:5:24: error: 'snuke2' was not declared in this scope; did you mean 'snuke'? 5 | int n, i, snuke = 0; snuke2 = 0, sum = 0, ans = 0, ans2 = 0; | ^~~~~~ | snuke a.cc:5:36: error: 'sum' was not declared in this scope 5 | int n, i, snuke = 0; snuke2 = 0, sum = 0, ans = 0, ans2 = 0; | ^~~ a.cc:5:45: error: 'ans' was not declared in this scope; did you mean 'abs'? 5 | int n, i, snuke = 0; snuke2 = 0, sum = 0, ans = 0, ans2 = 0; | ^~~ | abs a.cc:5:54: error: 'ans2' was not declared in this scope 5 | int n, i, snuke = 0; snuke2 = 0, sum = 0, ans = 0, ans2 = 0; | ^~~~
s729801993
p03659
C++
<?php $N = intval(trim(fgets(STDIN))); $tmp = trim(fgets(STDIN)); $a = array_map("intval", explode(" ", $tmp)); $l = 0; $left = []; $left[0] = 0; foreach($a as $value){ $l += $value; array_push($left, $l); } $r = 0; $right = []; $right[0] = 0; $r_a = array_reverse($a); foreach($r_a as $value){ $r += $value; array_push($right, $r); } $right = array_reverse($right); $ans = abs($right[1] - $left[1]); for($i = 2;$i<count($right)-1;$i++){ if($ans > abs($right[$i] - $left[$i])){ $ans = abs($right[$i] - $left[$i]); } } echo $ans . PHP_EOL;
a.cc:1:1: error: expected unqualified-id before '<' token 1 | <?php | ^ a.cc:3:1: error: '$tmp' does not name a type 3 | $tmp = trim(fgets(STDIN)); | ^~~~ a.cc:4:1: error: '$a' does not name a type 4 | $a = array_map("intval", explode(" ", $tmp)); | ^~ a.cc:6:1: error: '$l' does not name a type 6 | $l = 0; | ^~ a.cc:7:1: error: '$left' does not name a type 7 | $left = []; | ^~~~~ a.cc:8:1: error: '$left' does not name a type 8 | $left[0] = 0; | ^~~~~ a.cc:9:8: error: expected constructor, destructor, or type conversion before '(' token 9 | foreach($a as $value){ | ^ a.cc:14:1: error: '$r' does not name a type 14 | $r = 0; | ^~ a.cc:15:1: error: '$right' does not name a type 15 | $right = []; | ^~~~~~ a.cc:16:1: error: '$right' does not name a type 16 | $right[0] = 0; | ^~~~~~ a.cc:17:1: error: '$r_a' does not name a type 17 | $r_a = array_reverse($a); | ^~~~ a.cc:18:8: error: expected constructor, destructor, or type conversion before '(' token 18 | foreach($r_a as $value){ | ^ a.cc:22:1: error: '$right' does not name a type 22 | $right = array_reverse($right); | ^~~~~~ a.cc:24:1: error: '$ans' does not name a type 24 | $ans = abs($right[1] - $left[1]); | ^~~~ a.cc:25:1: error: expected unqualified-id before 'for' 25 | for($i = 2;$i<count($right)-1;$i++){ | ^~~ a.cc:25:12: error: '$i' does not name a type 25 | for($i = 2;$i<count($right)-1;$i++){ | ^~ a.cc:25:31: error: '$i' does not name a type 25 | for($i = 2;$i<count($right)-1;$i++){ | ^~ a.cc:31:1: error: 'echo' does not name a type 31 | echo $ans . PHP_EOL; | ^~~~
s223885003
p03659
C++
int main(){ #ifdef EVAL freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif int N; cin >> N; vector <int> v(N); long long int s = 0; for(int &i : v){ cin >> i; s += i; } long long int cur = 0,ans = LLONG_MAX; for(int &i : v){ s -= i; cur += i; ans = min(ans,abs(s - cur)); } cout << ans; }
a.cc: In function 'int main()': a.cc:7:9: error: 'cin' was not declared in this scope 7 | cin >> N; | ^~~ a.cc:8:9: error: 'vector' was not declared in this scope 8 | vector <int> v(N); | ^~~~~~ a.cc:8:17: error: expected primary-expression before 'int' 8 | vector <int> v(N); | ^~~ a.cc:10:22: error: 'v' was not declared in this scope 10 | for(int &i : v){ | ^ a.cc:14:37: error: 'LLONG_MAX' was not declared in this scope 14 | long long int cur = 0,ans = LLONG_MAX; | ^~~~~~~~~ a.cc:1:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' +++ |+#include <climits> 1 | int main(){ a.cc:15:22: error: 'v' was not declared in this scope 15 | for(int &i : v){ | ^ a.cc:18:31: error: 'abs' was not declared in this scope; did you mean 'ans'? 18 | ans = min(ans,abs(s - cur)); | ^~~ | ans a.cc:18:23: error: 'min' was not declared in this scope; did you mean 'main'? 18 | ans = min(ans,abs(s - cur)); | ^~~ | main a.cc:20:9: error: 'cout' was not declared in this scope 20 | cout << ans; | ^~~~
s215010122
p03659
C++
#include <bits/stdc++.h> using namespace std; int main(){ #ifdef EVAL freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif int N; cin >> N; vector <int> v(N); long long int s = 0; for(int &i : v){ cin >> i; s += i; } long long int cur = 0,ans = LLONG_MAX; for(int &i : v){ sum -= i; cur += i; ans = min(ans,abs(sum - cur)); } cout << ans; }
a.cc: In function 'int main()': a.cc:19:17: error: 'sum' was not declared in this scope 19 | sum -= i; | ^~~
s280490632
p03659
C++
#include <iostream> #include <math.h> #include <algorithm> #include <string> int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); long long int N; std::cin >> N; std::vector<long long int> a(N); for (auto& i : a)std::cin >> i; std::vector<long long int> cumsum(N + 1, 0ll); for (int i = 0; i < N; ++i)cumsum[i + 1] = cumsum[i] + a[i]; long long int ans = 1000000000 * 2 + 1; for (int i = 1; i < N; ++i) { long long int dif = abs( cumsum[N] - cumsum[i] - cumsum[i] ); ans = std::min(ans, dif); } std::cout << ans << std::endl; }
a.cc: In function 'int main()': a.cc:11:10: error: 'vector' is not a member of 'std' 11 | std::vector<long long int> a(N); | ^~~~~~ a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' 3 | #include <algorithm> +++ |+#include <vector> 4 | #include <string> a.cc:11:17: error: expected primary-expression before 'long' 11 | std::vector<long long int> a(N); | ^~~~ a.cc:12:20: error: 'a' was not declared in this scope 12 | for (auto& i : a)std::cin >> i; | ^ a.cc:14:10: error: 'vector' is not a member of 'std' 14 | std::vector<long long int> cumsum(N + 1, 0ll); | ^~~~~~ a.cc:14:10: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' a.cc:14:17: error: expected primary-expression before 'long' 14 | std::vector<long long int> cumsum(N + 1, 0ll); | ^~~~ a.cc:15:32: error: 'cumsum' was not declared in this scope 15 | for (int i = 0; i < N; ++i)cumsum[i + 1] = cumsum[i] + a[i]; | ^~~~~~ a.cc:15:60: error: 'a' was not declared in this scope 15 | for (int i = 0; i < N; ++i)cumsum[i + 1] = cumsum[i] + a[i]; | ^ a.cc:19:13: error: 'cumsum' was not declared in this scope 19 | cumsum[N] - cumsum[i] - cumsum[i] | ^~~~~~
s746168172
p03659
C++
#include <iostream> #include <string> #include <algorithm> #include <cmath> #include <cstdlib> #include <vector> using namespace std; int main(){ int n; long mn = LONG_MAX; cin >> n; vector<long> cs(n); cin >> cs[0]; for (int i = 1; i < n; ++i) { long x; cin >> x; cs[i] = cs[i - 1] + x; } for (int i = 0; i < n - 1; ++i) { mn = min(mn, abs(cs[i] - (cs[n - 1] - cs[i]))); } cout << mn << endl; }
a.cc: In function 'int main()': a.cc:11:19: error: 'LONG_MAX' was not declared in this scope 11 | long mn = LONG_MAX; | ^~~~~~~~ a.cc:7:1: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 6 | #include <vector> +++ |+#include <climits> 7 | using namespace std;
s055616110
p03659
C++
#include <iostream> #include <string> #include <algorithm> #include <vector> using namespace std; int main(){ int n,b; long long sum=0,sun=0,bacsun; vector <int> a; cin>>n; for(int i=0;i<n;i++){ cin>>b; a.push_back(b); sum+=b; } for(int i=0;i<n;i++){ sun+=a[i]; if(sun>sum/2){ break; } bacsun=sun; } if(sun==sum){ sun-=a[n-1]; } if(sun==0){ sun=a[0]j; } cout<<min(sun*2-sum,sum-bacsun*2)<<endl; return 0; }
a.cc: In function 'int main()': a.cc:28:25: error: expected ';' before 'j' 28 | sun=a[0]j; | ^ | ;
s367352732
p03659
C++
#include <bits/stdc++.h> using namespace std; int main() { long long double n,sum,x,y,ans; cin>>n; vector<long long int> a(n); sum=x=0; for(long int i=0;i<n;i++){ cin>>a[i]; sum+=a[i]; } for(long int i=0;i<n;i++){ y=x; x+=a[i]; if(x>sum/2){ if(abs(x-sum/2)>=abs(y-sum/2)) cout<<y<<endl; else cout<<x<<endl; return 0; } } }
a.cc: In function 'int main()': a.cc:5:8: error: 'long long' specified with 'double' 5 | long long double n,sum,x,y,ans; | ^~~~ a.cc:5:8: error: 'long long' specified with 'double' a.cc:5:8: error: 'long long' specified with 'double' a.cc:5:8: error: 'long long' specified with 'double' a.cc:5:8: error: 'long long' specified with 'double'
s445162137
p03659
C++
v#include<bits/stdc++.h> using namespace std; int n; long long a[200005],ans=1000000000000000000; long long x,y; int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>a[i]; y+=a[i]; } for(int i=0;i<n-1;i++){ x+=a[i]; y-=a[i]; ans=min(ans,abs(y-x)); } cout<<ans; return 0; }
a.cc:1:2: 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:7:9: error: 'cin' was not declared in this scope 7 | cin>>n; | ^~~ a.cc:15:29: error: 'abs' was not declared in this scope; did you mean 'ans'? 15 | ans=min(ans,abs(y-x)); | ^~~ | ans a.cc:15:21: error: 'min' was not declared in this scope; did you mean 'main'? 15 | ans=min(ans,abs(y-x)); | ^~~ | main a.cc:17:9: error: 'cout' was not declared in this scope 17 | cout<<ans; | ^~~~
s454480004
p03659
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n long long a[200005],x,s=0,ans=1e10,i; cin>>n; for(i=1;i<=n;i++){ cin>>a[i]; s+=a[i]; } for(i=1;i<n-1;i++){ x+=a[i]; ans=min(ans,abs(2*x-sum)); } cout<<ans; return 0; }
a.cc: In function 'int main()': a.cc:5:9: error: expected initializer before 'long' 5 | long long a[200005],x,s=0,ans=1e10,i; | ^~~~ a.cc:6:14: error: 'n' was not declared in this scope; did you mean 'yn'? 6 | cin>>n; | ^ | yn a.cc:7:13: error: 'i' was not declared in this scope 7 | for(i=1;i<=n;i++){ | ^ a.cc:8:22: error: 'a' was not declared in this scope 8 | cin>>a[i]; | ^ a.cc:9:17: error: 's' was not declared in this scope 9 | s+=a[i]; | ^ a.cc:11:13: error: 'i' was not declared in this scope 11 | for(i=1;i<n-1;i++){ | ^ a.cc:12:17: error: 'x' was not declared in this scope 12 | x+=a[i]; | ^ a.cc:12:20: error: 'a' was not declared in this scope 12 | x+=a[i]; | ^ a.cc:13:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 13 | ans=min(ans,abs(2*x-sum)); | ^~~ | abs a.cc:13:37: error: 'sum' was not declared in this scope 13 | ans=min(ans,abs(2*x-sum)); | ^~~ a.cc:15:15: error: 'ans' was not declared in this scope; did you mean 'abs'? 15 | cout<<ans; | ^~~ | abs
s658214007
p03659
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n long long a[200005],x,s=0,ans=1e10,i; cin>>n; for(i=1;i<=n;i++){ cin>>a[i; s+=a[i]; } for(i=1;i<n-1;i++){ x+=a[i]; ans=min(ans,abs(2*x-sum)); } cout<<ans; return 0; }
a.cc: In function 'int main()': a.cc:5:9: error: expected initializer before 'long' 5 | long long a[200005],x,s=0,ans=1e10,i; | ^~~~ a.cc:6:14: error: 'n' was not declared in this scope; did you mean 'yn'? 6 | cin>>n; | ^ | yn a.cc:7:13: error: 'i' was not declared in this scope 7 | for(i=1;i<=n;i++){ | ^ a.cc:8:22: error: 'a' was not declared in this scope 8 | cin>>a[i; | ^ a.cc:8:25: error: expected ']' before ';' token 8 | cin>>a[i; | ^ | ] a.cc:9:17: error: 's' was not declared in this scope 9 | s+=a[i]; | ^ a.cc:11:13: error: 'i' was not declared in this scope 11 | for(i=1;i<n-1;i++){ | ^ a.cc:12:17: error: 'x' was not declared in this scope 12 | x+=a[i]; | ^ a.cc:12:20: error: 'a' was not declared in this scope 12 | x+=a[i]; | ^ a.cc:13:17: error: 'ans' was not declared in this scope; did you mean 'abs'? 13 | ans=min(ans,abs(2*x-sum)); | ^~~ | abs a.cc:13:37: error: 'sum' was not declared in this scope 13 | ans=min(ans,abs(2*x-sum)); | ^~~ a.cc:15:15: error: 'ans' was not declared in this scope; did you mean 'abs'? 15 | cout<<ans; | ^~~ | abs
s211967046
p03659
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef unsigned long long ull; const int maxn=0x7fffff; long long a[1000000001]; ll ans=10000000000000000001; int main(){ long long n,i,sum=0; cin>n>>m; for(i=0;i<n;i++){ cin>>a[i]; sum+=a[i]; } for(i=0;i<n-1;i++){ x+=a[i]; ans=min(ans,abs(2*x-sum)); } cout<<ans; return 0; }
a.cc:8:8: warning: integer constant is so large that it is unsigned 8 | ll ans=10000000000000000001; | ^~~~~~~~~~~~~~~~~~~~ a.cc: In function 'int main()': a.cc:11:16: error: 'm' was not declared in this scope 11 | cin>n>>m; | ^ a.cc:17:17: error: 'x' was not declared in this scope 17 | x+=a[i]; | ^
s540171830
p03659
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n,a[200005],x,s=0,ans=1e10,i; cin>>n; for(i=1;i<=n;i++){ cin>>a[i; s+=a[i]; } for(i=1;i<n-1;i++){ x+=a[i]; ans=min(ans,abs(2*x-sum)); } cout<<ans; return 0; }
a.cc: In function 'int main()': a.cc:4:35: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+10' to '2147483647' [-Woverflow] 4 | int n,a[200005],x,s=0,ans=1e10,i; | ^~~~ a.cc:7:25: error: expected ']' before ';' token 7 | cin>>a[i; | ^ | ] a.cc:12:37: error: 'sum' was not declared in this scope 12 | ans=min(ans,abs(2*x-sum)); | ^~~
s087363796
p03659
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn=200005 int n; ll a[maxn],x,y,ans=10000000000000000LL; int main(){ cin>>n; for (int i=0;i<n;i++){ cin>>a[i]; sum+=a[i]; } for(int i=0;i<n-1;i++){ x+=a[i]; ans=min(ans,abs(2*x-sum)); } 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:8:14: error: 'n' was not declared in this scope; did you mean 'yn'? 8 | cin>>n; | ^ | yn a.cc:11:17: error: 'sum' was not declared in this scope 11 | sum+=a[i]; | ^~~ a.cc:15:37: error: 'sum' was not declared in this scope 15 | ans=min(ans,abs(2*x-sum)); | ^~~
s969200392
p03659
C++
#include<bits/stdc++.h> using namespace std; typedef long long ll; int n; ll a[maxn],x,y,ans=1000000000; int main(){ cin>>n; for (int i=0;i<=n;i++){ cin>>a[i]; y+=a[i]; } for(int i=0;i<n+1;i++){ x-=a[i]; y+=a[i]; ans=min(ans,abs(y-x)); } cout<<ans<<endl; return 0; }
a.cc:5:6: error: 'maxn' was not declared in this scope 5 | ll a[maxn],x,y,ans=1000000000; | ^~~~ a.cc: In function 'int main()': a.cc:9:22: error: 'a' was not declared in this scope 9 | cin>>a[i]; | ^ a.cc:13:20: error: 'a' was not declared in this scope 13 | x-=a[i]; | ^
s282799218
p03659
C++
#include<bist/stdc++.h> using namespace std; const int maxn = 200005; typedef long long LL; int n; LL a[maxn], x, y, ans = 1000000000000000000LL; int main(){ cin>>n; for (int i = 0; i < n; i ++){ cin>>a[i]; y += a[i]; } for(int i = 0; i < n - 1; i ++){ x += a[i]; y -= a[i]; ans = min(ans, abs(y - x)) } cout << ans <<endl; return 0; }
a.cc:1:9: fatal error: bist/stdc++.h: No such file or directory 1 | #include<bist/stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s648080172
p03659
C++
#include <vector> #include <iostream> #include <cmath> #include <string> #include <cstring> #include <algorithm> #include <numeric> #include <climits> using namespace std; int main(){ ios::sync_with_stdio(false); long long int n,ans=LLONG_MAX; cin>>n; vector<long long int>a(n); for(int i=0;i<n;i++) cin>>a[i]; long long int sum=accumulate(a.begin(),a.end(),0LL); for(int i=0;i<n;i++){ x+=a[i]; if(i+1<n)ans=min(ans,abs(sum-2*a[i])); } cout<<ans; }
a.cc: In function 'int main()': a.cc:19:9: error: 'x' was not declared in this scope 19 | x+=a[i]; | ^
s369919993
p03659
C++
N = int(input()) a = list(map(int, input().split())) X = sum(a) ans = [] for i in range(N): ans.append(abs(X - 2*sum(a[:i]))) print(min(ans))
a.cc:1:1: error: 'N' does not name a type 1 | N = int(input()) | ^
s317643453
p03659
C++
#include<bits/stdc++.h> using namespace std; typedef long long LL; const int MAXN=2e5+5; LL a[MAXN]; LL b[MAXN]; int main() { int n; while(cin>>n) { LL ans=0; for(int i=1;i<=n;i++) { cin>>a[i]; b[i]=b[i-1]+a[i]; ans+=a[i]; } LL cmin=INT_MAX; for(int i=1;i<n;i++) { if(cmin>abs(2*b[i]-tot)) cmin=abs(2*b[i]-tot); } cout<<cmin<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:22:32: error: 'tot' was not declared in this scope 22 | if(cmin>abs(2*b[i]-tot)) | ^~~
s033100103
p03659
C++
#include<bits/stdc++.h> using namespace std; int n, cmin = INT_MAX; vector <int> a; int main() { cin >> n; for (int i = 1; i <= n; i ++) { int x; cin >> x; a.push_back(x); } sort(a.begin(),a.end()); for (int i = a.begin(); i < a.end(); i ++) if (a[i + 1] - a[i] <= cmin) cmin = a[i + 1]- a[i]; cout << cmin; return 0; }
a.cc: In function 'int main()': a.cc:15:25: error: cannot convert 'std::vector<int>::iterator' to 'int' in initialization 15 | for (int i = a.begin(); i < a.end(); i ++) | ~~~~~~~^~ | | | std::vector<int>::iterator a.cc:15:31: error: no match for 'operator<' (operand types are 'int' and 'std::vector<int>::iterator') 15 | for (int i = a.begin(); i < a.end(); i ++) | ~ ^ ~~~~~~~ | | | | int std::vector<int>::iterator 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:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed: a.cc:15:39: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int' 15 | for (int i = a.begin(); i < a.end(); i ++) | ^ /usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed: a.cc:15:39: note: mismatched types 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' and 'int' 15 | for (int i = a.begin(); i < a.end(); i ++) | ^ /usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1317 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed: a.cc:15:39: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int' 15 | for (int i = a.begin(); i < a.end(); i ++) | ^ /usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed: a.cc:15:39: note: 'std::vector<int>::iterator' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 15 | for (int i = a.begin(); i < a.end(); i ++) | ^ /usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1485 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed: a.cc:15:39: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int' 15 | for (int i = a.begin(); i < a.end(); i ++) | ^ /usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed: a.cc:15:39: note: 'std::vector<int>::iterator' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 15 | for (int i = a.begin(); i < a.end(); i ++) | ^ /usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1660 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed: a.cc:15:39: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int' 15 | for (int i = a.begin(); i < a.end(); i ++) | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: a.cc:15:39: note: mismatched types 'const std::pair<_T1, _T2>' and 'int' 15 | for (int i = a.begin(); i < a.end(); i ++) | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: a.cc:15:39: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' 15 | for (int i = a.begin(); i < a.end(); i ++) | ^ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: a.cc:15:39: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' 15 | for (int i = a.begin(); i < a.end(); i ++) | ^ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: a.cc:15:39: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int' 15 | for (int i = a.begin(); i < a.end(); i ++) | ^ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: a.cc:15:39: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int' 15 | for (int i = a.begin(); i < a.end(); 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:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 673 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed: a.cc:15:39: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int' 15 | for (int i = a.begin(); i < a.end(); i ++) | ^ /usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 680 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed: a.cc:15:39: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int' 15 | for (int i = a.begin(); i < a.end(); i ++) | ^ /usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed: a.cc:15:39: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::basic_string_view<_CharT, _Traits>' 15 | for (int i = a.begin(); i < a.end(); i ++) | ^ /usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT,
s706848444
p03659
C++
#include<bits/stdc++.h> using namespace std; using ll = long long; #define MM 1000000000; #define mod MM + 7; #define INF (ll)1e18 #define pi acos(-1.0) #define MAX 100005 #define NIL -1 int main(){ ll n; cin >> n; ll a[n]; ll sum[n]; cin >> a[0]; sum[0] = a[0]; for(ll i = 1; i < n; i++){ cin >> a[i]; sum[i] = sum[i-1] + a[i]; } ll sum_all = sum[n-1]; ll mn = 100000000; for(ll i = 1; i < n; i++){ diff = abs(sum_all - sum[i-1] - sum[i-1]); mn = min(mn, diff); } cout << mn << endl; }
a.cc: In function 'int main()': a.cc:24:9: error: 'diff' was not declared in this scope 24 | diff = abs(sum_all - sum[i-1] - sum[i-1]); | ^~~~
s050508253
p03659
C++
#include <iostream> #include<vector> #include<algorithm> #include<string> using namespace std; #define REP(i,n) for(int i=0;i<n;i++) #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define INF 1000000000 int main(){ cin.tie(0); ios::sync_with_stdio(false); int N; cin>>N; long long int a=0,b=0,ans=INF; vector<int>A(N); REP(i,N){ cin>>A[i]; a+=A[i]; } REP(i,N-1){ b+=A[i]; //cout<<a<<" "<<b<<endl; ans=min(ans,abs(a-2*b); } cout<<ans<<endl; return 0; }
a.cc: In function 'int main()': a.cc:24:39: error: expected ')' before ';' token 24 | ans=min(ans,abs(a-2*b); | ~ ^ | )
s297043219
p03659
C++
#include <iostream> #include <string> #include <algorithm> #include <cmath> #include <cstdlib> using namespace std; int main(){ int n; long sum = 0; long ans = LONG_MAX; cin >> n; long aSum[200005]; for (int i = 0; i < n; i++) { long temp; cin >> temp; sum += temp; aSum[i] = sum; } for (int i = 0; i < n - 1; i++) { if (labs(aSum[i] * 2 - aSum[n - 1]) < ans) { ans = labs(aSum[i] * 2 - aSum[n - 1]); } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:11:20: error: 'LONG_MAX' was not declared in this scope 11 | long ans = LONG_MAX; | ^~~~~~~~ a.cc:6:1: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 5 | #include <cstdlib> +++ |+#include <climits> 6 | using namespace std;
s495186033
p03659
C++
#include <iostream> #include <string> #include <algorithm> #include <cmath> #include <cstdlib> using namespace std; int main(){ int n; long sum = 0; long ans = LONG_MAX; cin >> n; long aSum[200005]; for (int i = 0; i < n; i++) { long temp; cin >> temp; sum += temp; aSum[i] = sum; } for (int i = 0; i < n - 1; i++) { if (abs(aSum[i] * 2 - aSum[n - 1]) < ans) { ans = abs(aSum[i] * 2 - aSum[n - 1]); } } cout << ans << endl; }
a.cc: In function 'int main()': a.cc:11:20: error: 'LONG_MAX' was not declared in this scope 11 | long ans = LONG_MAX; | ^~~~~~~~ a.cc:6:1: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 5 | #include <cstdlib> +++ |+#include <climits> 6 | using namespace std;
s567050180
p03659
Java
import java.util.Scanner; import java.util.Arrays; import java.util.ArrayList; import java.util.List; import java.util.Collections; public class Main { public static void main(String args[]){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[] ar = new long[n]; long sum = 0; long abs = 1000000000000000; for (int i = 0; i < n; i++) { ar[i] = sc.nextLong(); sum += ar[i]; } for (int i = 0; i < n-1; i++) { sum = Math.abs(sum - 2*ar[i]); if (sum < abs) { abs = sum; } } System.out.println(abs); sc.close(); } public static boolean isEven(int n ) { if (n % 2 == 0) { return true; }else{ return false; } } }
Main.java:14: error: integer number too large long abs = 1000000000000000; ^ 1 error
s156696511
p03659
C++
#include<iostream> #include<vector> #include<numeric> #include<cmath> #include<climits> using namespace std; int main(){ int n; cin >> n; vector<long long int> card(n); for(int i = 0; i < n; i++){ cin >> card[i]; sum += card[i]; } //long long int sum = accumulate(card.begin(), card.end(), 0); long long int min = INT_MAX; for(int i = 0; i < n - 1; i++){ int sum1 = accumulate(card.begin(), card.end() - n + i + 1, 0); int sum2 = sum - sum1; if(min > fabs(sum1 - sum2)){ min = fabs(sum1 - sum2); } } cout << min << endl; return 0; }
a.cc: In function 'int main()': a.cc:14:9: error: 'sum' was not declared in this scope 14 | sum += card[i]; | ^~~ a.cc:21:20: error: 'sum' was not declared in this scope; did you mean 'sum2'? 21 | int sum2 = sum - sum1; | ^~~ | sum2
s610225217
p03659
C++
#include <bits/stdc++.h> #define int long long using namespace std; int n,a[200005],sum,cnt,ans=11111111111; int main(){ cin>>n; for(int i=0;i<n;i++){ cin>>a[i]; sum+=a[i]; } for(int i=0;i<n-1;i++){ cnt+=a[i]; ans=min(ans,abs((sum-cnt)-cnt)); } cout<<ans<<endl; }
cc1plus: error: '::main' must return 'int'
s537873394
p03659
C++
//inlclude前用define #define _USE_MATH_DEFINES //include #include<iostream> #include<string> #include<algorithm> #include<vector> #include<cmath> #include<cstdio> #include<type_traits> #include<numeric> //#include<deque> #include<limits> #include<iomanip> #include<set> using namespace std; //typedef typedef vector<int> VI; typedef vector<string> VS; typedef vector<char> VC; typedef long long int ll; //define #define INF 10000000000 //long long int専用 #define NUM 1000000007 #define all(x) begin(x), end(x) int main() { int n; cin >> n; VI a(n); ll sum=0,ans = INF,x=0; for (int i = 0; i < n; i++) { cin >> a[i]; } sort(all(a)); for (int i = 0; i < n; i++) sum += a[i]; for (int i = 0; i < n; i++) { x+= 2 * a[i]; if (min(ans, abs(sum - x)) == abs(sum - x))) { ans = abs(sum - x); } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:44:61: error: expected primary-expression before ')' token 44 | if (min(ans, abs(sum - x)) == abs(sum - x))) { | ^
s762438593
p03659
C++
#include <bits/stdc++.h> using namespace std; long long int min(long long int a, long long int b){ if(a<b){ return a; }else{ return b; } } long long int p(long long int a){ if(a<0){ a=-a; } return a; } int main() { int n long long int sum=0,ans=1000000000; long long int a[200000]; long long int sm[200000]; cin >> n; for(int i=0;i<n;i++){ cin >> a[i]; sum+=a[i]; sm[i]=sum; } for(int i=0;i<n-1;i++){ ans=min(ans,p(sm[i]*2-sum)); } if(n==2){ ans=p(a[0]-a[1]); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:22:5: error: expected initializer before 'long' 22 | long long int sum=0,ans=1000000000; | ^~~~ a.cc:25:12: error: 'n' was not declared in this scope 25 | cin >> n; | ^ a.cc:28:9: error: 'sum' was not declared in this scope; did you mean 'sm'? 28 | sum+=a[i]; | ^~~ | sm a.cc:32:9: error: 'ans' was not declared in this scope; did you mean 'abs'? 32 | ans=min(ans,p(sm[i]*2-sum)); | ^~~ | abs a.cc:32:31: error: 'sum' was not declared in this scope; did you mean 'sm'? 32 | ans=min(ans,p(sm[i]*2-sum)); | ^~~ | sm a.cc:35:9: error: 'ans' was not declared in this scope; did you mean 'abs'? 35 | ans=p(a[0]-a[1]); | ^~~ | abs a.cc:37:13: error: 'ans' was not declared in this scope; did you mean 'abs'? 37 | cout << ans << endl; | ^~~ | abs
s911806846
p03659
C++
#include <iostream> #include <vector> #include <string> #include <stack> #include <queue> #include <deque> #include <algorithm> #include <functional> #include <cstring> #include <cstdlib> #include <cmath> #include <climits> #define endl '\n' #define ll long long using namespace std; int main(void) { cin.tie(NULL); ios_base::sync_with_stdio(false); int N; cin >> N; ll acc = 0; int ret = INT_MAX; vector<int> cards; for(int i = 0; i < N; i++) { int temp; cin >> temp; cards.push_back(temp); acc += temp; } ll lhs = 0; for(int i = 0; i < N - 1; i++) { lhs += cards[i]; ll rhs = acc - lhs; ret = min(ret, abs(lhs - rhs)); } cout << ret; return 0; }
a.cc: In function 'int main()': a.cc:37:26: error: no matching function for call to 'min(int&, long long int)' 37 | ret = min(ret, abs(lhs - rhs)); | ~~~^~~~~~~~~~~~~~~~~~~~~ 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:37:26: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int') 37 | ret = min(ret, abs(lhs - rhs)); | ~~~^~~~~~~~~~~~~~~~~~~~~ /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:7: /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:37:26: note: mismatched types 'std::initializer_list<_Tp>' and 'int' 37 | ret = min(ret, abs(lhs - rhs)); | ~~~^~~~~~~~~~~~~~~~~~~~~
s438599367
p03659
C
#include <stdio.h> int main(void) { int n,i,ans,sum=0,suma,sumb,com; int a[200001]; int suma[200001]; scanf("%d",&n); for(i=0;i<n;i++){ scanf("%d",&a[i]); sum+=a[i]; suma[i]=sum; } for(i=0;i<n;i++){ sumb=sum-suma[i]; if(sumb>suma[i]){ com=sumb-suma[i]; }else{ com=suma[i]-sumb; } if(i==0){ ans=com; }else if(com<ans){ ans=com; } } printf("%d",ans); return 0; }
main.c: In function 'main': main.c:6:13: error: conflicting types for 'suma'; have 'int[200001]' 6 | int suma[200001]; | ^~~~ main.c:4:27: note: previous declaration of 'suma' with type 'int' 4 | int n,i,ans,sum=0,suma,sumb,com; | ^~~~
s760276613
p03659
C++
#include <iostream> #include <algorithm> #include <climits> #include <cmath> #include <vector> using namespace std; int main(){ int N; cin >> N; vector<long long> a(N); for(int i = 0; i < N; i++) cin >> a[i]; ll sum = 0; for(int i = 0; i < N; i++){ sum += a[i]; if(i == 0)continue; a[i] += a[i - 1]; } long long ans = LLONG_MAX; for(int i = 0; i < N; i++){ ans = min(ans, abs(a[i] - (sum - a[i]))); } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:14:3: error: 'll' was not declared in this scope 14 | ll sum = 0; | ^~ a.cc:16:9: error: 'sum' was not declared in this scope 16 | sum += a[i]; | ^~~ a.cc:23:36: error: 'sum' was not declared in this scope 23 | ans = min(ans, abs(a[i] - (sum - a[i]))); | ^~~
s479183685
p03659
C++
#include <bits/stdc++.h> using namespace std; int main(){ long long ans,n,array[100000],snuke,kuma=0; cin>>n; for(int i=0;i<n;i++){ cin>>array[i]; if(i){ kuma+=array[i]; } } snuke=array[i]; ans=abs(snuke-kuma); for(int i=1;i<n-1;i++){ snuke+=array[i]; kuma-=array[i]; ans=min(ans,abs(snuke-kuma)); } cout<<ans<<endl; }
a.cc: In function 'int main()': a.cc:13:15: error: 'i' was not declared in this scope 13 | snuke=array[i]; | ^
s775283756
p03659
C++
#pragma GCC optimize(3) #pragma GCC optimize("Ofast") #pragma GCC optimize("inline") #pragma GCC optimize("-fgcse") #pragma GCC optimize("-fgcse-lm") #pragma GCC optimize("-fipa-sra") #pragma GCC optimize("-ftree-pre") #pragma GCC optimize("-ftree-vrp") #pragma GCC optimize("-fpeephole2") #pragma GCC optimize("-ffast-math") #pragma GCC optimize("-fsched-spec") #pragma GCC optimize("unroll-loops") #pragma GCC optimize("-falign-jumps") #pragma GCC optimize("-falign-loops") #pragma GCC optimize("-falign-labels") #pragma GCC optimize("-fdevirtualize") #pragma GCC optimize("-fcaller-saves") #pragma GCC optimize("-fcrossjumping") #pragma GCC optimize("-fthread-jumps") #pragma GCC optimize("-funroll-loops") #pragma GCC optimize("-fwhole-program") #pragma GCC optimize("-freorder-blocks") #pragma GCC optimize("-fschedule-insns") #pragma GCC optimize("inline-functions") #pragma GCC optimize("-ftree-tail-merge") #pragma GCC optimize("-fschedule-insns2") #pragma GCC optimize("-fstrict-aliasing") #pragma GCC optimize("-fstrict-overflow") #pragma GCC optimize("-falign-functions") #pragma GCC optimize("-fcse-skip-blocks") #pragma GCC optimize("-fcse-follow-jumps") #pragma GCC optimize("-fsched-interblock") #pragma GCC optimize("-fpartial-inlining") #pragma GCC optimize("no-stack-protector") #pragma GCC optimize("-freorder-functions") #pragma GCC optimize("-findirect-inlining") #pragma GCC optimize("-fhoist-adjacent-loads") #pragma GCC optimize("-frerun-cse-after-loop") #pragma GCC optimize("inline-small-functions") #pragma GCC optimize("-finline-small-functions") #pragma GCC optimize("-ftree-switch-conversion") #pragma GCC optimize("-foptimize-sibling-calls") #pragma GCC optimize("-fexpensive-optimizations") #pragma GCC optimize("-funsafe-loop-optimizations") #pragma GCC optimize("inline-functions-called-once") #pragma GCC optimize("-fdelete-null-pointer-checks") #include <cstdio> #define ll long long #define abs(a) ((a)>0?(a):(-a)) #define min(a,b) ((a)<(b)?(a):(b)) using namespace std; ll n,a[110000],tot,ans=922372036854775805; int main() { scanf("%lld",&n); for(register ll i=1; i<=n; ++i) scanf("%lld",&a[i]),tot+=a[i]; for(register ll i=1; i<=n-1; ++i) tot-=2*a[i],ans=min(ans,llabs(tot)); printf("%lld\n",ans); return 0; }
a.cc:21:39: warning: bad option '-fwhole-program' to pragma 'optimize' [-Wpragmas] 21 | #pragma GCC optimize("-fwhole-program") | ^ a.cc:28:41: warning: bad option '-fstrict-overflow' to pragma 'optimize' [-Wpragmas] 28 | #pragma GCC optimize("-fstrict-overflow") | ^ a.cc:30:41: warning: bad option '-fcse-skip-blocks' to pragma 'optimize' [-Wpragmas] 30 | #pragma GCC optimize("-fcse-skip-blocks") | ^ a.cc:44:51: warning: bad option '-funsafe-loop-optimizations' to pragma 'optimize' [-Wpragmas] 44 | #pragma GCC optimize("-funsafe-loop-optimizations") | ^ a.cc:53:10: warning: bad option '-fwhole-program' to attribute 'optimize' [-Wattributes] 53 | int main() | ^ a.cc:53:10: warning: bad option '-fstrict-overflow' to attribute 'optimize' [-Wattributes] a.cc:53:10: warning: bad option '-fcse-skip-blocks' to attribute 'optimize' [-Wattributes] a.cc:53:10: warning: bad option '-funsafe-loop-optimizations' to attribute 'optimize' [-Wattributes] a.cc: In function 'int main()': a.cc:56:25: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 56 | for(register ll i=1; i<=n; ++i) scanf("%lld",&a[i]),tot+=a[i]; | ^ a.cc:57:25: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister] 57 | for(register ll i=1; i<=n-1; ++i) | ^ a.cc:58:41: error: 'llabs' was not declared in this scope; did you mean 'abs'? 58 | tot-=2*a[i],ans=min(ans,llabs(tot)); | ^~~~~ a.cc:50:24: note: in definition of macro 'min' 50 | #define min(a,b) ((a)<(b)?(a):(b)) | ^
s249999866
p03659
C++
#include<bits/stdc++.h> using namespace std; long long n,m,s,x,b[20010]; int main(){ cin>>n; for(i=0;cin>>x;i++){ if(!i) b[i]=x; else b[i]=b[i-1]+x; s+=x; } if(b[0]>s-b[0]) m=b[0]+b[0]-s; else m=s-b[0]-b[0]; for(int i=1;i<(n-1);i++) m=max(m,abs(s-b[i]-b[i])); cout<<m<<endl; return 0; }
a.cc: In function 'int main()': a.cc:6:9: error: 'i' was not declared in this scope 6 | for(i=0;cin>>x;i++){ | ^
s625377132
p03659
C++
#include<bits/stdc++.h> using namespace std; long long n,m,s,x,b[20010]; int main(){ cin>>n; while(cin>>x){ if(!i) b[i]=x; else b[i]=b[i-1]+x; s+=x; } if(b[0]>s-b[0]) m=b[0]+b[0]-s; else m=s-b[0]-b[0]; for(int i=1;i<(n-1);i++) m=max(m,abs(s-b[i]-b[i])); cout<<m<<endl; return 0; }
a.cc: In function 'int main()': a.cc:7:13: error: 'i' was not declared in this scope 7 | if(!i) b[i]=x; | ^
s867662232
p03659
C++
#include<stdio.h> int main() { cout<<1; }
a.cc: In function 'int main()': a.cc:4:1: error: 'cout' was not declared in this scope 4 | cout<<1; | ^~~~
s137997092
p03659
C++
#include <bits/stdc++.h> typedef long long ll; using namespace std; int A[200000]; int main() { int n cin >> n; for (int i = 0; i < n; ++i) { cin >> A[i]; } ll sum = accumulate(A, A+n, 0); int ind = 0; ll sum_t = 0; while(sum_t < sum/2)sum_t+=A[ind++]; if(ind < n && ind -2){ cout << min(abs(2*sum_t - sum),abs(2*(sum_t + A[ind]) - sum)); } else if(ind == n)cout << abs(2*A[n-1]- sum); else cout << abs(2*A[0] - sum); }
a.cc: In function 'int main()': a.cc:8:5: error: expected initializer before 'cin' 8 | cin >> n; | ^~~ a.cc:9:25: error: 'n' was not declared in this scope 9 | for (int i = 0; i < n; ++i) { | ^ a.cc:12:30: error: 'n' was not declared in this scope; did you mean 'yn'? 12 | ll sum = accumulate(A, A+n, 0); | ^ | yn