submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3
values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s707774791 | p03661 | C | #include <stdio.h>
int main(){
int length;
int arr[200000];
int res[200000]={0};
int temp = 0;
int m = (2e5)*(1e9);
scanf("%d",&length);
for(int i=0;i<length;++i){
scanf("%d",&arr[i]);
}
res[0] = arr[0];
for(int i=1;i<length;++i){
res[i] += res[i-1] + arr[i];
}
for(int i=1;i<length;++i){
temp = abs(res[length-1]-res[i-1]*2);
m = min(temp,m);
}
printf("%d\n", m);
return 0;
} | main.c: In function 'main':
main.c:9:13: warning: overflow in conversion from 'double' to 'int' changes value from '2.0e+14' to '2147483647' [-Woverflow]
9 | int m = (2e5)*(1e9);
| ^
main.c:19:16: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
19 | temp = abs(res[length-1]-res[i-1]*2);
| ^~~
main.c:2:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
1 | #include <stdio.h>
+++ |+#include <stdlib.h>
2 |
main.c:20:13: error: implicit declaration of function 'min'; did you mean 'main'? [-Wimplicit-function-declaration]
20 | m = min(temp,m);
| ^~~
| main
|
s983463044 | p03661 | C |
#include <cstdio>
#include <stdio.h>
int main(){
int length;
int arr[200000];
int res[200000]={0};
int temp = 0;
int m = (2e5)*(1e9);
scanf("%d",&length);
for(int i=0;i<length;++i){
scanf("%d",&arr[i]);
}
res[0] = arr[0];
for(int i=1;i<length;++i){
res[i] += res[i-1] + arr[i];
}
for(int i=1;i<length;++i){
temp = abs(res[length-1]-res[i-1]*2);
m = min(temp,m);
}
printf("%d\n", m);
return 0;
}
| main.c:2:10: fatal error: cstdio: No such file or directory
2 | #include <cstdio>
| ^~~~~~~~
compilation terminated.
|
s324549049 | p03661 | C++ | int value(int a, int b) {
if (a > b) {
return a - b;
}
else {
return b - a;
}
}
int main() {
int n;
int sum1 = 0;
int sum = 0;
int min = 2e+9;
scanf("%d", &n);
int *a;
a = (int *)malloc(n * sizeof(int));
for (int i = 0; i < n; i++) {
scanf("%d", &a[i]);
sum += a[i];
}
for (int i = 0; i < n - 1; i++) {
sum1 += a[i];
if (value(2*sum1, sum) < min) {
min = value(2*sum1, sum);
}
}
printf("%d", min);
return 0;
}
| a.cc: In function 'int main()':
a.cc:15:9: error: 'scanf' was not declared in this scope
15 | scanf("%d", &n);
| ^~~~~
a.cc:18:20: error: 'malloc' was not declared in this scope
18 | a = (int *)malloc(n * sizeof(int));
| ^~~~~~
a.cc:1:1: note: 'malloc' is defined in header '<cstdlib>'; this is probably fixable by adding '#include <cstdlib>'
+++ |+#include <cstdlib>
1 | int value(int a, int b) {
a.cc:30:9: error: 'printf' was not declared in this scope
30 | printf("%d", min);
| ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
+++ |+#include <cstdio>
1 | int value(int a, int b) {
|
s822944507 | p03661 | C | #include<stdio.h>
long long int abs_1(long long int i){
if(i<0) return -i;
else return i;
}
int main()
{
int N,i,j;
scanf("%d",&N);
long long int a[N]={0},x,min=2*(10e9);
long long int sum1=0,sum2=0;
for(i=0;i<N;i++)
{
scanf("%lld",&a[i]);
}
for(i=0;i<N-1;i++)
{
for(j=i;j>=0;j--)
{
sum1+=a[j];
}
for(j=N-i;j<N;j++)
{
sum2+=a[j];
}
x=abs_1(sum1-sum2);
if(x<=min)
{
min=x;
}
}
printf("%lld",min);
return 0;
} | main.c: In function 'main':
main.c:10:28: error: variable-sized object may not be initialized except with an empty initializer
10 | long long int a[N]={0},x,min=2*(10e9);
| ^
|
s178909261 | p03661 | C | #include<stdio.h>
long int abs_1(long int i){
if(i<0) return -i;
else return i;
}
int main()
{
int N,i,j;
scanf("%d",&N);
long long int a[N]={0},x,min=2*(10e9);
long long int sum1=0,sum2=0;
for(i=0;i<N;i++)
{
scanf("%lld",&a[i]);
}
for(i=0;i<N-1;i++)
{
for(j=i;j>=0;j--)
{
sum1+=a[j];
}
for(j=N-i;j<N;j++)
{
sum2+=a[j];
}
x=abs_1(sum1-sum2);
if(x<=min)
{
min=x;
}
}
printf("%lld",min);
return 0;
} | main.c: In function 'main':
main.c:10:28: error: variable-sized object may not be initialized except with an empty initializer
10 | long long int a[N]={0},x,min=2*(10e9);
| ^
|
s001980349 | p03661 | C | #include<stdio.h>
long long int abs_1(long long int i){
if(i<0) return -i;
else return i;
}
int main()
{
long int N,i,j;
scanf("%ld",&N);
long long int a[N]={0},x,min=2*(10e9);
long long int sum1=0,sum2=0;
for(i=0;i<N;i++)
{
scanf("%lld",&a[i]);
}
for(i=0;i<N-1;i++)
{
for(j=i;j>=0;j--)
{
sum1+=a[j];
}
for(j=N-i;j<N;j++)
{
sum2+=a[j];
}
x=abs_1(sum1-sum2);
if(x<=min)
{
min=x;
}
}
printf("%lld",min);
return 0;
} | main.c: In function 'main':
main.c:10:28: error: variable-sized object may not be initialized except with an empty initializer
10 | long long int a[N]={0},x,min=2*(10e9);
| ^
|
s264930507 | p03661 | C++ | #include <cmath>
using namespace std;
const int N = 200000;
int a[N],b[N];
int n;
void init()
{
cin >> n;
for(int i=0; i<n; i++)
{
scanf("%d",&a[i]);
}
}
void solve()
{
int sum=0,x=0,y=0;
for(int i=1; i<n; i++)
{
sum += a[i];
}
int min = abs(a[0] - sum);
int current = min;
for(int i=0; i<n-1; i++)
{
y = 0;
b[i] = a[i];
x += b[i];
for(int j=i+1; j<n; j++)
{
y += a[j];
}
current = abs(x-y);
if(current < min)
min = current;
}
cout << min;
cout << endl;
}
int main()
{
init();
solve();
return 0;
}
| a.cc: In function 'void init()':
a.cc:8:5: error: 'cin' was not declared in this scope
8 | cin >> n;
| ^~~
a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
1 | #include <cmath>
+++ |+#include <iostream>
2 | using namespace std;
a.cc:11:9: error: 'scanf' was not declared in this scope
11 | scanf("%d",&a[i]);
| ^~~~~
a.cc: In function 'void solve()':
a.cc:38:5: error: 'cout' was not declared in this scope
38 | cout << min;
| ^~~~
a.cc:38:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:39:13: error: 'endl' was not declared in this scope
39 | cout << endl;
| ^~~~
a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
1 | #include <cmath>
+++ |+#include <ostream>
2 | using namespace std;
|
s351009989 | p03661 | C++ | #include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int a[10];
int n, min;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i];
sort(a[0], a[0] + n);
for (int j = 1; j < n; j++)
{
min = abs(a[1] - a[0]);
if (min > abs(a[1] - a[0]))
min = abs(a[j + 1] - a[j]);
}
cout << min;
return 0;
} | In file included from /usr/include/c++/14/algorithm:61,
from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h: In instantiation of 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]':
/usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp);
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
1908 | std::__final_insertion_sort(__first, __last, __comp);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4772:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = int]'
4772 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter());
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:11:6: required from here
11 | sort(a[0], a[0] + n);
| ~~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1780:17: error: no type named 'value_type' in 'struct std::iterator_traits<int>'
1780 | __val = _GLIBCXX_MOVE(*__i);
| ^~~~~
In file included from /usr/include/c++/14/bits/exception_ptr.h:41,
from /usr/include/c++/14/exception:166,
from /usr/include/c++/14/ios:41,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:1780:25: error: invalid type argument of unary '*' (have 'int')
1780 | __val = _GLIBCXX_MOVE(*__i);
| ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1782:15: error: invalid type argument of unary '*' (have 'int')
1782 | *__first = _GLIBCXX_MOVE(__val);
| ^~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
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:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = int; _Iterator2 = int]':
/usr/include/c++/14/bits/stl_algo.h:1777:14: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
1777 | if (__comp(__i, __first))
| ~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp);
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
1908 | std::__final_insertion_sort(__first, __last, __comp);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4772:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = int]'
4772 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter());
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:11:6: required from here
11 | sort(a[0], a[0] + n);
| ~~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:45:16: error: invalid type argument of unary '*' (have 'int')
45 | { return *__it1 < *__it2; }
| ^~~~~~
/usr/include/c++/14/bits/predefined_ops.h:45:25: error: invalid type argument of unary '*' (have 'int')
45 | { return *__it1 < *__it2; }
| ^~~~~~
In file included from /usr/include/c++/14/bits/stl_algo.h:61:
/usr/include/c++/14/bits/stl_heap.h: In instantiation of 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]':
/usr/include/c++/14/bits/stl_algo.h:1593:23: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
1593 | std::__make_heap(__first, __middle, __comp);
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1868:25: required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
1868 | std::__heap_select(__first, __middle, __last, __comp);
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1884:27: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = int; _Size = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
1884 | std::__partial_sort(__first, __last, __last, __comp);
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1905:25: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
1905 | std::__introsort_loop(__first, __last,
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
1906 | std::__lg(__last - __first) * 2,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1907 | __comp);
| ~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4772:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = int]'
4772 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter());
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:11:6: required from here
11 | sort(a[0], a[0] + n);
| ~~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:344:11: error: no type named 'value_type' in 'struct std::iterator_traits<int>'
344 | _ValueType;
| ^~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:346:11: error: no type named 'difference_type' in 'struct std::iterator_traits<int>'
346 | _DistanceType;
| ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h: In instantiation of 'void std::__pop_heap(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]':
/usr/include/c++/14/bits/stl_algo.h:1596:19: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
1596 | std::__pop_heap(__first, __middle, __i, __comp);
| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1868:25: required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
1868 | std::__heap_select(__first, __middle, __last, __comp);
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1884:27: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = int; _Size = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
1884 | std::__partial_sort(__first, __last, __last, __comp);
| ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:1905:25: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = int; _Compare = __gnu_cxx::__ops::_Iter_less_iter]'
1905 | std::__introsort_loop(__first, __last,
| ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
1906 | std::__lg(__last - __first) * 2,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1907 | __comp);
| ~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4772:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = int]'
4772 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter());
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:11:6: required from here
11 | sort(a[0], a[0] + n);
| ~~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:258:9: error: no type named 'value_type' in 'struct std::iterator_traits<int>'
258 | _ValueType;
| ^~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:260:9: error: no type named 'difference_type' in 'struct std::iterator_traits<int>'
260 | _DistanceType;
| ^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_heap.h:262:28: error: invalid type argument of unary '*' |
s363204721 | p03661 | C | #include<stdio.h>
long long int abs_1(long long int i){
if(i<0) return -i;
else return i;
}
int main()
{
long int N,i,j;
scanf("%ld",&N);
long long int a[N]={0},x,min=2*(10e9);
long long int sum1=0,sum2=0;
for(i=0;i<N;i++)
{
scanf("%lld",&a[i]);
}
for(i=0;i<N-1;i++)
{
for(j=i;j>=0;j--)
{
sum1+=a[j];
}
for(j=N-i;j<N;j++)
{
sum2+=a[j];
}
x=abs_1(sum1-sum2);
if(x<=min)
{
min=x;
}
}
printf("%lld",min);
return 0;
} | main.c: In function 'main':
main.c:10:28: error: variable-sized object may not be initialized except with an empty initializer
10 | long long int a[N]={0},x,min=2*(10e9);
| ^
|
s708651167 | p03661 | C | #include<stdio.h>
long long int abs_1(long long int i){
if(i<0) return -i;
else return i;
}
int main()
{
long int N,i,j;
scanf("%ld",&N);
long long int a[N]={0},x,min=2*(10e9);
long long int sum1=0,sum2=0;
for(i=0;i<N;i++)
{
scanf("%lld",&a[i]);
}
for(i=0;i<N-1;i++)
{
for(j=i;j>=0;j--)
{
sum1+=a[j];
}
for(j=N-i;j<N;j++)
{
sum2+=a[j];
}
x=abs_1(sum1-sum2);
if(x<=min)
{
min=x;
}
}
printf("%lld",min);
return 0;
} | main.c: In function 'main':
main.c:10:28: error: variable-sized object may not be initialized except with an empty initializer
10 | long long int a[N]={0},x,min=2*(10e9);
| ^
|
s022675100 | p03661 | C | #include<stdio.h>
#include<math.h>
int main()
{
int num,i,*p,*q;
scanf("%d",&num);
int s[sum];
long long d[num-1],x,y,min;
for(i=0;i<num;i++)
scanf("%lld",&s[i]);
for(i=0;i<num-1;i++)
{
x=0;
y=0;
p=s;
q=s+i+1;
while(p<q)
x=x+*p++;
while(q<s+num)
y=y+*q++;
d[i]=fabs(x-y);
}
min=d[0];
for(i=1;i<num-1;i++)
{
if(min>d[i])
min=d[i];
}
printf("%lld",min);
}
| main.c: In function 'main':
main.c:7:11: error: 'sum' undeclared (first use in this function); did you mean 'num'?
7 | int s[sum];
| ^~~
| num
main.c:7:11: note: each undeclared identifier is reported only once for each function it appears in
|
s689725476 | p03661 | C++ | #include<stdio.h>
#include<cmath>
int main(){
int sum[max],a[max],n,total=0,min;
scanf("%d",&n);
sum[0]=0;
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
sum[i]=sum[i-1]+a[i];
total+=a[i];
}
min=total;
for(int i=1;i<=n;i++){
if(min>abs(total-2*sum[i]))
min=abs(total-2*sum[i]);
}
printf("%d",min);
} | a.cc: In function 'int main()':
a.cc:6:17: error: 'max' was not declared in this scope; did you mean 'std::max'?
6 | int sum[max],a[max],n,total=0,min;
| ^~~
| std::max
In file included from /usr/include/c++/14/bits/specfun.h:43,
from /usr/include/c++/14/cmath:3906,
from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: 'std::max' declared here
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
a.cc:10:9: error: 'sum' was not declared in this scope
10 | sum[0]=0;
| ^~~
a.cc:12:29: error: 'a' was not declared in this scope
12 | scanf("%d",&a[i]);
| ^
|
s910711591 | p03661 | C | #include<stdio.h>
#include<math.h>
#define Min(a,b) (((a)>(b))?(b):(a))
int main()
{
int n;
while((scanf("%d",&n)!=EOF)&&(n!=0))
{
int i;
int a[200000];
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
int ss[n-1]={0};//用来存储x的和
int s=0;
for(i=0;i<n;i++)
{
s=s+a[i];
}//计算出总和
for(i=0;i<n-1;i++)
{
int j;
for(j=0;j<i+1;j++)
{
ss[i]=ss[i]+a[j];
}
}
int c[n-1];
for(i=0;i<n-1;i++)
{
c[i]=abs(2*ss[i]-s);
}
int min=c[0];
for(i=1;i<n-1;i++)
{
min=Min(min,c[i]);
}
printf("%d",min);
}
return 0;
} | main.c: In function 'main':
main.c:15:29: error: variable-sized object may not be initialized except with an empty initializer
15 | int ss[n-1]={0};//用来存储x的和
| ^
main.c:32:30: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
32 | c[i]=abs(2*ss[i]-s);
| ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
2 | #include<math.h>
+++ |+#include <stdlib.h>
3 | #define Min(a,b) (((a)>(b))?(b):(a))
|
s695307794 | p03661 | C | #include<stdio.h>
#include<math.h>
#define Min(a,b) (((a)>(b))?(b):(a))
int main()
{
int n;
while((scanf("%d",&n)!=EOF)&&(n!=0))
{
int i;
int a[200000];
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
int sum[n-1]={0};//用来存储x的和
int s=0;
for(i=0;i<n;i++)
{
s=s+a[i];
}//计算出总和
for(i=0;i<n-1;i++)
{
int j;
for(j=0;j<i+1;j++)
{
sum[i]=sum[i]+a[j];
}
}
int c[n-1];
for(i=0;i<n-1;i++)
{
c[i]=abs(2*sum[i]-s);
}
int min=c[0];
for(i=1;i<n-1;i++)
{
min=Min(min,c[i]);
}
printf("%d",min);
}
return 0;
} | main.c: In function 'main':
main.c:15:30: error: variable-sized object may not be initialized except with an empty initializer
15 | int sum[n-1]={0};//用来存储x的和
| ^
main.c:32:30: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration]
32 | c[i]=abs(2*sum[i]-s);
| ^~~
main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs'
2 | #include<math.h>
+++ |+#include <stdlib.h>
3 | #define Min(a,b) (((a)>(b))?(b):(a))
|
s792549316 | p03661 | C++ | #include<bits/stdc++.h>
using namespace std;
int main()
{
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
ll *a = new ll[n];
ll* b = new ll[n];
int tmp = 0;
while (n--)
cin >> a[tmp++];
b[0] = a[0];
for (int i = 1; i < tmp; i++)
b[i] =b[i-1]+ a[i];
ll min = abs(b[tmp-1] - 2 * b[0]);
for (int i = 1; i < tmp - 1; i++)
min =((min > abs(b[tmp-1] - 2 * b[i])) ? (abs(b[tmp-1] - 2 * b[i])) : min);
cout << min << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:10:9: error: 'll' was not declared in this scope
10 | ll *a = new ll[n];
| ^~
a.cc:10:13: error: 'a' was not declared in this scope
10 | ll *a = new ll[n];
| ^
a.cc:10:21: error: 'll' does not name a type
10 | ll *a = new ll[n];
| ^~
a.cc:11:13: error: 'b' was not declared in this scope
11 | ll* b = new ll[n];
| ^
a.cc:11:21: error: 'll' does not name a type
11 | ll* b = new ll[n];
| ^~
a.cc:18:11: error: expected ';' before 'min'
18 | ll min = abs(b[tmp-1] - 2 * b[0]);
| ^~~~
| ;
a.cc:21:14: error: no match for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and '<unresolved overloaded function type>')
21 | cout << min << endl;
| ~~~~~^~~~~~
In file included from /usr/include/c++/14/istream:41,
from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
from a.cc:1:
/usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'}
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]'
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ^~~~~~~~
/usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::ios_base& (*)(std::ios_base&)'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
174 | operator<<(long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long int'
174 | operator<<(long __n)
| ~~~~~^~~
/usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
178 | operator<<(unsigned long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long unsigned int'
178 | operator<<(unsigned long __n)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
182 | operator<<(bool __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'bool'
182 | operator<<(bool __n)
| ~~~~~^~~
In file included from /usr/include/c++/14/ostream:1022:
/usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]'
96 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short int'
97 | operator<<(short __n)
| ~~~~~~^~~
/usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
189 | operator<<(unsigned short __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short unsigned int'
189 | operator<<(unsigned short __n)
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]'
110 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int'
111 | operator<<(int __n)
| ~~~~^~~
/usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
200 | operator<<(unsigned int __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'unsigned int'
200 | operator<<(unsigned int __n)
| ~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
211 | operator<<(long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int'
211 | operator<<(long long __n)
| ~~~~~~~~~~^~~
/usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
215 | operator<<(unsigned long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long unsigned int'
215 | operator<<(unsigned long long __n)
| ~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
231 | operator<<(double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'double'
231 | operator<<(double __f)
| ~~~~~~~^~~
/usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
235 | operator<<(float __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'float'
235 | operator<<(float __f)
| ~~~~~~^~~
/usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
243 | operator<<(long double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long double'
243 | operator<<(long double __f)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(c |
s273807096 | p03661 | C++ | #include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>
#define MOD 1000000007;
#define PI 3.14159265358979323846;
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int main()
{
int N;
cin >> N;
int S[200001];
for (int i = 0; i < N; i++)
{
cin >> S[i];
}
for (int i = 0; i < N; i++)
{
S[i + 1] = S[i + 1] + S[i];
}
ll minValue = LLONG_MAX;
for (int i = 0; i < N - 1; i++) {
ll x = S[i];
ll y = S[N - 1] - S[i];
minValue = min(minValue, abs(x - y));
}
cout << minValue << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:31:23: error: 'LLONG_MAX' was not declared in this scope
31 | ll minValue = LLONG_MAX;
| ^~~~~~~~~
a.cc:9:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
8 | #include <cmath>
+++ |+#include <climits>
9 |
|
s371259796 | p03661 | C++ | #include<iostream>
using namespace std;
__int64 Wa=0;
__int64 Hand[100000];
__int64 Sa[2];
__int64 ans=0;
int main(){
int N;
int a[100000];
int i,j,k;
cin>>N;
for(i=0;i<N;i++){
cin>>a[i];
Wa=Wa+a[i];
if(i!=N-1){
Hand[i]=Wa;
}
}
k=0;
Sa[0]=Wa-(Hand[0]*2);
if(Sa[0]<0){Sa[0]=-1*Sa[0];}
for(i=1;i<N-1 && k==0;i++){
Sa[1]=Wa-(2*Hand[i]);
if(Sa[1]<0){Sa[1]=-1*Sa[1];}
if(Sa[0]>Sa[1]){
ans=Sa[1];
Sa[0]=Sa[1];
}else{
k=1;
}
}
cout<<ans;
}
| a.cc:3:9: error: '__int64' does not name a type; did you mean '__int64_t'?
3 | __int64 Wa=0;
| ^~~~~~~
| __int64_t
a.cc:4:9: error: '__int64' does not name a type; did you mean '__int64_t'?
4 | __int64 Hand[100000];
| ^~~~~~~
| __int64_t
a.cc:5:9: error: '__int64' does not name a type; did you mean '__int64_t'?
5 | __int64 Sa[2];
| ^~~~~~~
| __int64_t
a.cc:6:9: error: '__int64' does not name a type; did you mean '__int64_t'?
6 | __int64 ans=0;
| ^~~~~~~
| __int64_t
a.cc: In function 'int main()':
a.cc:18:17: error: 'Wa' was not declared in this scope; did you mean 'a'?
18 | Wa=Wa+a[i];
| ^~
| a
a.cc:20:25: error: 'Hand' was not declared in this scope; did you mean 'rand'?
20 | Hand[i]=Wa;
| ^~~~
| rand
a.cc:24:9: error: 'Sa' was not declared in this scope; did you mean 'a'?
24 | Sa[0]=Wa-(Hand[0]*2);
| ^~
| a
a.cc:24:15: error: 'Wa' was not declared in this scope; did you mean 'a'?
24 | Sa[0]=Wa-(Hand[0]*2);
| ^~
| a
a.cc:24:19: error: 'Hand' was not declared in this scope; did you mean 'rand'?
24 | Sa[0]=Wa-(Hand[0]*2);
| ^~~~
| rand
a.cc:30:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
30 | ans=Sa[1];
| ^~~
| abs
a.cc:37:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
37 | cout<<ans;
| ^~~
| abs
|
s387332957 | p03661 | C++ | #include<iostream>
using namespace std;
__int64 Wa=0;
__int64 Hand[100000];
__int64 Sa[2];
__int64 ans=0;
int main(){
int N;
int a[100000];
int i,j,k;
cin>>N;
for(i=0;i<N;i++){
cin>>a[i];
Wa=Wa+a[i];
if(i!=N-1){
Hand[i]=Wa;
}
}
k=0;
Sa[0]=Wa-(Hand[0]*2);
if(Sa[0]<0){Sa[0]=-1*Sa[0];}
for(i=1;i<N-1 && k==0;i++){
Sa[1]=Wa-(2*Hand[i]);
if(Sa[1]<0){Sa[1]=-1*Sa[1];}
if(Sa[0]>Sa[1]){
ans=i;
Sa[0]=Sa[1];
}else{
k=1;
}
}
ans=Wa-(Hand[ans]*2);
if(ans<0){ans=(ans*-1);}
cout<<ans;
}
| a.cc:3:9: error: '__int64' does not name a type; did you mean '__int64_t'?
3 | __int64 Wa=0;
| ^~~~~~~
| __int64_t
a.cc:4:9: error: '__int64' does not name a type; did you mean '__int64_t'?
4 | __int64 Hand[100000];
| ^~~~~~~
| __int64_t
a.cc:5:9: error: '__int64' does not name a type; did you mean '__int64_t'?
5 | __int64 Sa[2];
| ^~~~~~~
| __int64_t
a.cc:6:9: error: '__int64' does not name a type; did you mean '__int64_t'?
6 | __int64 ans=0;
| ^~~~~~~
| __int64_t
a.cc: In function 'int main()':
a.cc:18:17: error: 'Wa' was not declared in this scope; did you mean 'a'?
18 | Wa=Wa+a[i];
| ^~
| a
a.cc:20:25: error: 'Hand' was not declared in this scope; did you mean 'rand'?
20 | Hand[i]=Wa;
| ^~~~
| rand
a.cc:24:9: error: 'Sa' was not declared in this scope; did you mean 'a'?
24 | Sa[0]=Wa-(Hand[0]*2);
| ^~
| a
a.cc:24:15: error: 'Wa' was not declared in this scope; did you mean 'a'?
24 | Sa[0]=Wa-(Hand[0]*2);
| ^~
| a
a.cc:24:19: error: 'Hand' was not declared in this scope; did you mean 'rand'?
24 | Sa[0]=Wa-(Hand[0]*2);
| ^~~~
| rand
a.cc:30:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
30 | ans=i;
| ^~~
| abs
a.cc:36:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
36 | ans=Wa-(Hand[ans]*2);
| ^~~
| abs
|
s784267630 | p03661 | C++ | #include <iostream>
#include <cmath>
typedef long long ll;
using namespace std;
int main(){
int N; cin >> N;
int a[N];
ll sum = 0LL;
for(int i=0; i<N; i++){
cin >> a[i];
sum += a[i];
}
ll sunuke = 0LL;
ll ans = (ll) 2e9 + 1LL;
for(int i=0; i<N-1; i++){
sunuke += a[i];
ans = min(ans, abs(sum-sunuke));
}
cout << abs(sunuke-araiguma) << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:24:24: error: 'araiguma' was not declared in this scope
24 | cout << abs(sunuke-araiguma) << endl;
| ^~~~~~~~
|
s567563844 | p03661 | C++ | #include<iostream>
using namespace std;
__int64 a[200005];
int main(){
int n;
int x,y;
cin>>n;
int i=0;
for(i=0;i<n;i++){
cin>>a[i];
}
x=a[0];
y=a[i-1];
int ans;
ans=x-y;
if(ans<0)ans=-ans;
for(i=1;i<n-1;i++){
ans-=a[i];
if(ans<0)ans=-ans;
}
cout<<ans<<endl;
return 0;
}
| a.cc:3:1: error: '__int64' does not name a type; did you mean '__int64_t'?
3 | __int64 a[200005];
| ^~~~~~~
| __int64_t
a.cc: In function 'int main()':
a.cc:10:22: error: 'a' was not declared in this scope
10 | cin>>a[i];
| ^
a.cc:12:11: error: 'a' was not declared in this scope
12 | x=a[0];
| ^
|
s666240892 | p03661 | C++ | #include<bits/stdc++.h>
using namespace std;
int n;
int a[200001];
long long abs(long long x){
if(x<0)return -x;
return x;
}
long long x=0,y=0;
int main(){
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
y+=a[i];
}
long long minn=1e18;
if(y<minn)minn=y;
for(int i=0;i<n;i++){
x+=a[i];
y-=a[i];
if(abs(x-y)<minn)minn=abs(x-y);
}
cout<<minn<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:21:23: error: call of overloaded 'abs(long long int)' is ambiguous
21 | if(abs(x-y)<minn)minn=abs(x-y);
| ~~~^~~~~
In file included from /usr/include/c++/14/cstdlib:79,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42,
from a.cc:1:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:5:11: note: candidate: 'long long int abs(long long int)'
5 | long long abs(long long x){
| ^~~
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: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:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/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:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/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:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
a.cc:21:42: error: call of overloaded 'abs(long long int)' is ambiguous
21 | if(abs(x-y)<minn)minn=abs(x-y);
| ~~~^~~~~
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:5:11: note: candidate: 'long long int abs(long long int)'
5 | long long abs(long long x){
| ^~~
/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: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:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/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:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/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:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
|
s780654561 | p03661 | C++ | #include<bits/stdc++.h>
using namespace std;
int n;
int a[200001];
long long abs(long long x){
if(x<0)return -x;
return x;
}
long long x=0,y=0;
int main(){
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
y+=a[i];
}
long long minn=1e18;
if(y<minn)minn=y;
for(int i=0;i<n;i++){
x+=a[i];
y-=a[i];
if(abs(x-y)<minn)minn=abs(x-y);
}
cout<<minn<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:21:23: error: call of overloaded 'abs(long long int)' is ambiguous
21 | if(abs(x-y)<minn)minn=abs(x-y);
| ~~~^~~~~
In file included from /usr/include/c++/14/cstdlib:79,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42,
from a.cc:1:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:5:11: note: candidate: 'long long int abs(long long int)'
5 | long long abs(long long x){
| ^~~
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: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:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/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:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/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:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
a.cc:21:42: error: call of overloaded 'abs(long long int)' is ambiguous
21 | if(abs(x-y)<minn)minn=abs(x-y);
| ~~~^~~~~
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:5:11: note: candidate: 'long long int abs(long long int)'
5 | long long abs(long long x){
| ^~~
/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: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:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/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:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/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:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
|
s815410480 | p03661 | C++ | #include<bits/stdc++.h>
using namespace std;
int n;
int a[200001];
long long abs(int x){
if(x<0)return -x;
return x;
}
long long x=0,y=0;
int main(){
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
y+=a[i];
}
long long minn=1e18;
if(y<minn)minn=y;
for(int i=0;i<n;i++){
x+=a[i];
y-=a[i];
if(abs(x-y)<minn)minn=abs(x-y);
}
cout<<minn<<endl;
return 0;
} | a.cc:5:11: error: ambiguating new declaration of 'long long int abs(int)'
5 | long long abs(int x){
| ^~~
In file included from /usr/include/c++/14/cstdlib:79,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42,
from a.cc:1:
/usr/include/stdlib.h:980:12: note: old declaration 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
|
s952549242 | p03661 | C++ | #include<bits/stdc++.h>
using namespace std;
int a[100001],sum[100001];
int main()
{
int n,temp,ans;
while(scanf("%d",&n)){
a[0]=0;
for(int i=1;i<=n;i++){
scanf("%lld",&temp);
a[i]=a[i-1]+temp;
}
ans=abs(a[n]-a[1]-a[1]);
for(int i=2;i<n;i++) ans=min(ans,abs(a[n]-a[i]-a[i]));
printf("%d\n",minn);
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:17:23: error: 'minn' was not declared in this scope
17 | printf("%d\n",minn);
| ^~~~
|
s295945553 | p03661 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second
ll ones(int x){
ll ret=0;
for(;x--;) ret=10*ret+1;
return ret;
}
ll get_kth(int k){
--k;
ll ret = 0;
for(int dep=1; dep<=9; ++dep){
if(!k && dep>1){
break;
}
if(dep>1) --k;
for(int i=(dep==1); i<=9; ++i){
if(ones(10-dep) <= k){
k -= ones(10-dep);
} else {
ret=10*ret + i;
break;
}
}
}
return ret;
}
bool Test(ll x){
printf("? %lld\n", x);
fflush(stdout);
char buf[5]; scanf("%s", buf);
return buf[0] == 'Y';
}
int main()
{
if(Test(1e9)) printf("! %d\n", int(1e9));
else {
ll l=1, r=1e9;
while(l < r){
ll mid=(l+r)/2;
ll q = get_kth(mid)
while(q <= ll(1e10)) q*=10;
if(Test(q)) r=mid;
else l=mid+1;
}
printf("! %lld\n", l);
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:57:25: error: expected ',' or ';' before 'while'
57 | while(q <= ll(1e10)) q*=10;
| ^~~~~
|
s828788000 | p03661 | C++ | #include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<cmath>
#define ll long long
using namespace std;
const int maxn=2e5+3;
int a[maxn];
ll sum,n;
int main()
{
scanf("%lld",&n);
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
sum+=a[i];
}
ll ans=LONG_LONG_MAX;
ll tmp=0;
for(int i=0;i<n-1;i++)
{
tmp+=a[i];
ans=min(ans,abs(sum-tmp-tmp));
}
printf("%d\n",ans);
} | a.cc: In function 'int main()':
a.cc:19:16: error: 'LONG_LONG_MAX' was not declared in this scope
19 | ll ans=LONG_LONG_MAX;
| ^~~~~~~~~~~~~
|
s026318622 | p03661 | C++ | #include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<cmath>
#define ll long long
using namespace std;
const int maxn=2e5+3;
int a[maxn];
ll sum,n;
int main()
{
scanf("%lld",&n);
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
sum+=a[i];
}
ll ans=LONG_LONG_MAX;
ll tmp=0;
for(int i=0;i<n-1;i++)
{
tmp+=a[i];
ans=min(ans,abs(sum-tmp-tmp));
}
printf("%d\n",ans);
} | a.cc: In function 'int main()':
a.cc:19:16: error: 'LONG_LONG_MAX' was not declared in this scope
19 | ll ans=LONG_LONG_MAX;
| ^~~~~~~~~~~~~
|
s106934062 | p03661 | C++ | 1 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 1
| ^
|
s364763045 | p03661 | Java | import java.util.Scanner;
public class ABBADiv1 {
private static int x; //前者の和
private static int y; //後者の和
private static int N;
private static int a[];
private static int ans = 1000000000;
public static void sum(int index){
for(int i=0;i<index;i++){
x += a[i];
}
for(int i=index;i<N;i++){
y += a[i];
}
}
public static void input(){
Scanner scan = new Scanner(System.in);
N = scan.nextInt();
a = new int[N];
for(int i=0;i<N;i++) {
a[i] = scan.nextInt();
}
}
public static void main(String args[]){
input();
for(int index=1;index<N;index++){
sum(index);
if(Math.abs(x-y) < ans){
ans = Math.abs(x-y);
}
x = 0;//初期化
y = 0;//初期化
}
System.out.println(ans);
}
}
| Main.java:3: error: class ABBADiv1 is public, should be declared in a file named ABBADiv1.java
public class ABBADiv1 {
^
1 error
|
s598279739 | p03661 | C++ | test | a.cc:1:1: error: 'test' does not name a type
1 | test
| ^~~~
|
s572473031 | p03661 | C++ | test | a.cc:1:1: error: 'test' does not name a type
1 | test
| ^~~~
|
s939906660 | p03661 | C++ | test | a.cc:1:1: error: 'test' does not name a type
1 | test
| ^~~~
|
s999446073 | p03661 | C++ | a | a.cc:1:1: error: 'a' does not name a type
1 | a
| ^
|
s671313956 | p03661 | C++ | test | a.cc:1:1: error: 'test' does not name a type
1 | test
| ^~~~
|
s269164303 | p03661 | C++ | test | a.cc:1:1: error: 'test' does not name a type
1 | test
| ^~~~
|
s235466410 | p03661 | C++ | test | a.cc:1:1: error: 'test' does not name a type
1 | test
| ^~~~
|
s506191963 | p03661 | C++ | test | a.cc:1:1: error: 'test' does not name a type
1 | test
| ^~~~
|
s454555830 | p03661 | C++ | test | a.cc:1:1: error: 'test' does not name a type
1 | test
| ^~~~
|
s810911202 | p03661 | C++ | test | a.cc:1:1: error: 'test' does not name a type
1 | test
| ^~~~
|
s170171188 | p03661 | C++ | #include<bits/stdc++.h>
int main()
{
typedef long long ll;
ll x,sum[200009],n,ans,minn;
scanf("%lld",&n);
sum[0]=0;
ll i=1;
for(i=1;i<=n;i++)
{
scanf("%lld",&x);
sum[i]=sum[i-1]+x;
}
ans=sum[n];
minn=abs(2*sum[1]-sum[n]);
for(i=2;i<=n-1;i++)
{
minn=min(minn,abs(2*sum[i]-sum[n]));
}
printf("%lld\n",minn);
return 0;
} | a.cc: In function 'int main()':
a.cc:18:14: error: 'min' was not declared in this scope; did you mean 'std::min'?
18 | minn=min(minn,abs(2*sum[i]-sum[n]));
| ^~~
| std::min
In file included from /usr/include/c++/14/algorithm:61,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
|
s661086086 | p03661 | C++ | #include<bits/stdc++.h>
int main()
{
typedef long long ll;
ll x,sum[200009],n,ans,minn;
scanf("%lld",&n);
sum[0]=0;
ll i=1;
for(i=1;i<=n;i++)
{
scanf("%lld",&x);
sum[i]=sum[i-1]+x;
}
ans=sum[n];
minn=abs(2*sum[1]-sum[n]);
for(i=2;i<=n-1;i++)
{
minn=min(minn,abs(2*sum[i]-sum[n]));
}
printf("%lld\n",minn);
return 0;
} | a.cc: In function 'int main()':
a.cc:18:14: error: 'min' was not declared in this scope; did you mean 'std::min'?
18 | minn=min(minn,abs(2*sum[i]-sum[n]));
| ^~~
| std::min
In file included from /usr/include/c++/14/algorithm:61,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
|
s421713265 | p03661 | C++ | int main(){
int n;
long long X=0,x=0,ans=1000000000000000000LL;
cin>>n;
vector<long long> a(n);
for(int i=0;i<n;i++){
cin>>a[i];
X+=a[i];
}
for(int i=0;i<n;i++){
x+=a[i];
if(i+1<n)ans=min(ans,abs(X-2*x));
}
cout<<ans<<endl;
} | a.cc: In function 'int main()':
a.cc:4:1: error: 'cin' was not declared in this scope
4 | cin>>n;
| ^~~
a.cc:5:1: error: 'vector' was not declared in this scope
5 | vector<long long> a(n);
| ^~~~~~
a.cc:5:8: error: expected primary-expression before 'long'
5 | vector<long long> a(n);
| ^~~~
a.cc:7:6: error: 'a' was not declared in this scope
7 | cin>>a[i];
| ^
a.cc:11:4: error: 'a' was not declared in this scope
11 | x+=a[i];
| ^
a.cc:12:22: error: 'abs' was not declared in this scope; did you mean 'ans'?
12 | if(i+1<n)ans=min(ans,abs(X-2*x));
| ^~~
| ans
a.cc:12:14: error: 'min' was not declared in this scope; did you mean 'main'?
12 | if(i+1<n)ans=min(ans,abs(X-2*x));
| ^~~
| main
a.cc:14:1: error: 'cout' was not declared in this scope
14 | cout<<ans<<endl;
| ^~~~
a.cc:14:12: error: 'endl' was not declared in this scope
14 | cout<<ans<<endl;
| ^~~~
|
s727852934 | p03661 | C++ | #include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORd(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << "\n"
#define _ << " _ " <<
#define ll long long
using namespace std;
bool pitaj(ll x) {
cout << "? " << x << "\n";
char t;
cin >> t;
return (t == 'Y');
}
int main() {
ios_base::sync_with_stdio(false);
bool A = pitaj(1000000000);
if (A) {
ll x = 1;
while (!pitaj(2 * x)) {x *= 10;}
cout << "! " << x << "\n";
} else {
ll x = 1;
while (pitaj(x)) {
x *= 10;
l++;
}
x /= 10;
ll lo = x, hi = x * 10 - 1;
while (lo < hi) {
ll mi = lo + (hi - lo) / 2;
bool b = pitaj(10 * mi);
if (b) {
hi = mi;
} else {
lo = mi + 1;
}
}
cout << "! " << lo << "\n";
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:31:7: error: 'l' was not declared in this scope
31 | l++;
| ^
|
s269450538 | p03661 | C++ | #include <cstdint>
#include <iostream>
#include <vector>
using namespace std;
#define GRAPH_SIZE 100000
enum status_t {
WHITE,
BLACK,
};
static uint32_t tree[GRAPH_SIZE][GRAPH_SIZE];
static vector<uint32_t> distance_from0;
static vector<uint32_t> distance_fromN;
static vector<status_t> status;
static void dist(uint32_t index, size_t num, uint32_t d, vector<uint32_t> &distances)
{
status[index] = BLACK;
for (uint32_t i = 0; i < num; i++) {
if ((tree[index][i] != 0) && (status[i] != BLACK)) {
distances[i] = d;
dist(i, num, d + 1, distances);
}
}
}
int32_t main()
{
uint32_t num;
cin >> num;
for (uint32_t i = 0; i < num; i++) {
for (uint32_t j = 0; j < num; j++) {
tree[i][j] = 0;
}
}
distance_from0.resize(num, 0);
distance_fromN.resize(num, 0);
for (uint32_t i = 0; i < num; i++) {
uint32_t a, b;
cin >> a >> b;
tree[a][b] = 1;
tree[b][a] = 1;
}
status.clear();
status.resize(num, WHITE);
dist(0, num, 0, distance_from0);
status.clear();
status.resize(num, WHITE);
dist(num, num, 0, distance_fromN);
uint32_t black = 0, white = 0;
for (uint32_t i = 0; i < num; i++) {
if (distance_from0[i] <= distance_fromN[i]) {
black++;
} else {
white++;
}
}
if (white <= black) {
cout << "Fennec" << endl;
} else {
cout << "Sunuke" << endl;
}
return 0;
}
| /tmp/ccK7x27n.o: in function `dist(unsigned int, unsigned long, unsigned int, std::vector<unsigned int, std::allocator<unsigned int> >&)':
a.cc:(.text+0x20): relocation truncated to fit: R_X86_64_PC32 against `.bss'
a.cc:(.text+0x6d): relocation truncated to fit: R_X86_64_PC32 against `.bss'
/tmp/ccK7x27n.o: in function `main':
a.cc:(.text+0x165): relocation truncated to fit: R_X86_64_PC32 against `.bss'
a.cc:(.text+0x18a): relocation truncated to fit: R_X86_64_PC32 against `.bss'
a.cc:(.text+0x231): relocation truncated to fit: R_X86_64_PC32 against `.bss'
a.cc:(.text+0x256): relocation truncated to fit: R_X86_64_PC32 against `.bss'
a.cc:(.text+0x26a): relocation truncated to fit: R_X86_64_PC32 against `.bss'
a.cc:(.text+0x283): relocation truncated to fit: R_X86_64_PC32 against `.bss'
a.cc:(.text+0x2a8): relocation truncated to fit: R_X86_64_PC32 against `.bss'
a.cc:(.text+0x2bf): relocation truncated to fit: R_X86_64_PC32 against `.bss'
a.cc:(.text+0x2f2): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s022983177 | p03661 | C++ | #include<bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
long long int n, a[222222];
cin >> n;
cin >> a[0];
for(int i=1; i<n; ++i){
int t; cin >> t;
a[i]=a[i-1]+t;
}
int mi=1e10;
for(int i=0; i<n-1; ++i){
mi = min(abs(a[i]-(a[n-1]-a[i])), mi);
// cout << a[n-1]-a[i] -a[i] << "\n";
}
cout << mi << "\n";
return 0;
}
| a.cc: In function 'int main()':
a.cc:13:12: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+10' to '2147483647' [-Woverflow]
13 | int mi=1e10;
| ^~~~
a.cc:15:17: error: no matching function for call to 'min(long long int, int&)'
15 | mi = min(abs(a[i]-(a[n-1]-a[i])), mi);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:15:17: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
15 | mi = min(abs(a[i]-(a[n-1]-a[i])), mi);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:15:17: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
15 | mi = min(abs(a[i]-(a[n-1]-a[i])), mi);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s349138405 | p03661 | C++ | #include <iostream>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;
u64 abs(l64 a)
{
if (a>0) return a;
return -a;
}
int main(void)
{
cin.tie(0);
ios::sync_with_stdio(false);
u64 n;
cin >> n;
l64 a[n];
l64 sum = 0;
for (u64 i = 0; i < n; ++i) {
cin >> a[i];
sum += a[i];
}
u64 snuke = a[0];
u64 diff = abs(sum-snuke*2);
for (u64 i = 1; i < n-1; ++i) {
snuke += a[i];
diff = min(diff, abs(sum-snuke*2));
}
cout << diff << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:25:17: error: call of overloaded 'abs(long long unsigned int)' is ambiguous
25 | u64 diff = abs(sum-snuke*2);
| ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
from /usr/include/c++/14/ext/string_conversions.h:43,
from /usr/include/c++/14/bits/basic_string.h:4154,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:6:5: note: candidate: 'u64 abs(l64)'
6 | u64 abs(l64 a)
| ^~~
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: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:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/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:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/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:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
a.cc:28:25: error: call of overloaded 'abs(long long unsigned int)' is ambiguous
28 | diff = min(diff, abs(sum-snuke*2));
| ~~~^~~~~~~~~~~~~
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:6:5: note: candidate: 'u64 abs(l64)'
6 | u64 abs(l64 a)
| ^~~
/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: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:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/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:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/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:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
|
s907510132 | p03661 | C | #include <iostream>
#include <string>
#include <vector>
#include <cmath>
using namespace std;
int INF = 1 << 20;
int main(){
int N;
vector<int> a;
cin >> N;
for(int i = 0; i < N; i++){
int tmp;
cin >> tmp;
a.push_back(tmp);
}
int min = INF;
int count = 1;
while(1){
if(count == N) break;
bool flag = false;
int x = 0, y = 0;
for(int i = 0; i < N; i++){
if(i == count) flag = true;
if(flag) y += a[i];
else x += a[i];
}
int tmp = abs(x - y);
if(min > tmp) min = tmp;
count++;
}
cout << min << endl;
return 0;
} | main.c:1:10: fatal error: iostream: No such file or directory
1 | #include <iostream>
| ^~~~~~~~~~
compilation terminated.
|
s958453882 | p03661 | Java | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int[] arr=new int[n];
int sum=0;
for (int i = 0; i < arr.length; i++) {
arr[i]=sc.nextInt();
sum+=arr[i];
}
int temp=0;
int min=Integer.MAX_VALUE;
for (int i = 0; i < arr.length-1; ++i) {
temp+=arr[i];
min=Math.min(min, Math.abs((sum-temp)-temp);
}
System.out.println(min);
}
} | Main.java:20: error: ')' or ',' expected
min=Math.min(min, Math.abs((sum-temp)-temp);
^
1 error
|
s828938695 | p03661 | Java | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int[] arr=new int[n];
int sum=0;
for (int i = 0; i < arr.length; i++) {
arr[i]=sc.nextInt();
sum+=arr[i];
}
int temp=0;
int min=Integer.MAX_VALUE;
for (int i = 0; i < arr.length; i++) {
temp+=arr[i];
min=Math.min(min, Math.abs(sum-2*temp));
}
System.out.println(min);
}
| Main.java:24: error: reached end of file while parsing
}
^
1 error
|
s486060617 | p03661 | Java | public class Main {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
int[] arr=new int[n];
for (int i = 0; i < arr.length; i++) {
arr[i]=sc.nextInt();
}
int min=Integer.MAX_VALUE;
int x=arr[0];int y=arr[n-1];
int r=n-1;
int l=0;
if(arr.length==2)
{
System.out.println(arr[0]-arr[1]);
return;
}
for (int i = 1; i < arr.length; i++) {
if(x<y)
{
x+=arr[l];
l++;
}
else
{
y+=arr[r];
r--;
}
//System.out.println(x+" " +y);
}
System.out.println(Math.abs(x-y));
}
}
| Main.java:5: error: cannot find symbol
Scanner sc=new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:5: error: cannot find symbol
Scanner sc=new Scanner(System.in);
^
symbol: class Scanner
location: class Main
2 errors
|
s479835364 | p03661 | C++ | 复制代码
#include<cstdio>
#include<vector>
#include<algorithm>
#define MN 2100001
using namespace std;
int n,m,a[MN],x,y,fa[MN],s[MN],d[MN];
vector<int> v[MN];
void dfs(int x,int f){
fa[x]=f;s[x]=1;
for (int i=0;i<v[x].size();i++)
if (v[x][i]!=f){
d[v[x][i]]=d[x]+1;
dfs(v[x][i],x);
s[x]+=s[v[x][i]];
}
}
int main(){
scanf("%d",&n);
for (int i=1;i<n;i++){
scanf("%d%d",&x,&y);
v[x].push_back(y);v[y].push_back(x);
}
dfs(1,0);
x=n;y=d[x]-(d[x]-1>>1);
while (d[x]!=y) x=fa[x];
if (n-s[x]>s[x]) puts("Fennec");else puts("Snuke");
} | a.cc:1:1: error: '\U0000590d\U00005236\U00004ee3\U00007801' does not name a type
1 | 复制代码
| ^~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/vector:62,
from a.cc:3:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
In file included from /usr/include/stdio.h:34,
from /usr/include/c++/14/cstdio:42,
from a.cc:2:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared
2086 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope
2087 | struct remove_extent<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid
2087 | struct remove_extent<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared
2099 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope
2100 | struct remove_all_extents<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid
2100 | struct remove_all_extents<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared
2171 | template<std::size_t _Len>
| ^~~
/usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope
2176 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared
2194 | template<std::size_t _Len, std::size_t _Align =
| ^~~
/usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^~~~
/usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid
2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)>
| ^
/usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope
2202 | unsigned char __data[_Len];
| ^~~~
/usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope
2203 | struct __attribute__((__aligned__((_Align)))) { } __align;
| ^~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:65:
/usr/include/c++/14/bits/stl_iterator_base_types.h:125:67: error: 'ptrdiff_t' does not name a type
125 | template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:1:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
+++ |+#include <cstddef>
1 | // Types used in iterator implementation -*- C++ -*-
/usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: error: 'ptrdiff_t' does not name a type
214 | typedef ptrdiff_t difference_type;
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: error: 'ptrdiff_t' does not name a type
225 | typedef ptrdiff_t difference_type;
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
In file included from /usr/include/c++/14/bits/stl_algobase.h:66:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:112:5: error: 'ptrdiff_t' does not name a type
112 | ptrdiff_t
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:66:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
65 | #include <debug/assertions.h>
+++ |+#include <cstddef>
66 | #include <bits/stl_iterator_base_types.h>
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: error: 'ptrdiff_t' does not name a type
118 | ptrdiff_t
| ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
In file included from /usr/include/c++/14/bits/stl_iterator.h:67,
from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/ptr_traits.h:156:47: error: 'ptrdiff_t' was not d |
s685723431 | p03661 | C++ | // Dont hack this or I hack ur mama
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define EPS (1e-9)
using namespace std;
////////////// END OF TEMPLATE
const int nmax = 200010;
ll sum;
int a[nmax],n;
void read()
{
cin >> n;
for(int i = 0 ; i < n; ++i)
{
cin >> a[i];
sum+=a[i];
}
}
void solve()
{
ll preSum = 0;
ll ans = abs(2LL*a[i] - sum);
for(int i = 0;i < n-1 ; ++i)
{
preSum+=a[i];
sum-=a[i];
ans = min(ans, abs(preSum - sum));
}
cout << ans << endl;
}
int main()
{
std::ios::sync_with_stdio(false);
read();
solve();
return 0;
}
| a.cc: In function 'void solve()':
a.cc:34:28: error: 'i' was not declared in this scope
34 | ll ans = abs(2LL*a[i] - sum);
| ^
|
s490237955 | p03661 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int n;
while(cin >> n) {
vector<int> vec(n, 0);
//vector<long long> presum(n, 0);
long long vsum, hlf, lhlf, dis, tmp;
dis = LLONG_MAX;
vsum = 0;
for(int i=0; i<n; i++) {
cin >> vec[i];
vsum += vec[i];
}
lhlf = 0;
for(int i=0; i<n; i++) {
lhlf += vec[i];
tmp = abs(vsum - (lhlf << 1));
if(dis > tmp)
dis = tmp;
if(dis == 0)
break;
}
cout << dis << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:14:23: error: 'LLONG_MAX' was not declared in this scope
14 | dis = LLONG_MAX;
| ^~~~~~~~~
a.cc:4:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
3 | #include <algorithm>
+++ |+#include <climits>
4 |
|
s657232865 | p03661 | C++ | #include <iostream>
int checked[40000][16];
long long dp[40000][16];
long long esum[40000];
using namespace std;
int eds[16][16];
int n,m;
long long calc(int state,int now);
long long calc_sub(int state_base,int state,int dep,int now,int prev) {
if(dep==n) {
return esum[state_base-state]+eds[now][prev]+calc(state,prev);
}
long long ret=0;
if(dep==prev) {
ret=calc_sub(state_base,state+(1<<dep),dep+1,now,prev);
} else if(dep==now) {
ret=calc_sub(state_base,state,dep+1,now,prev);
} else {
ret=calc_sub(state_base,state,dep+1,now,prev);
if(state_base&(1<<dep)) {
long long temp=calc_sub(state_base,state+(1<<dep),dep+1,now,prev);
if(ret<temp) ret=temp;
}
}
return ret;
}
long long calc(int state,int now) {
if(checked[state][now]) return dp[state][now];
checked[state][now]=1;
if(now==0) {
dp[state][now]=esum[state];
} else {
dp[state][now]=-1e16;
for(int i=0;i<n;i++) {
if((state&(1<<i))>0&&i!=now&&eds[i][now]>0) {
long long temp=calc_sub(state,1,1,now,i);
if(dp[state][now]<temp) dp[state][now]=temp;
}
}
}
return dp[state][now];
}
int main() {
cin >> n >> m;
for(int i=0;i<m;i++) {
int va,vb,vc;
cin >> va >> vb >> vc;
va--; vb--;
eds[va][vb]=vc;
eds[vb][va]=vc;
}
for(int i=0;i<(1<<n);i++) {
for(int j=0;j<n;j++) for(int k=j+1;k<n;k++) {
if((i&(1<<j))>0&&(i&(1<<k))>0) esum[i]+=eds[j][k];
}
}
cout << esum[(1<<n)-1]-calc((1<<n)-1,n-1) << endl;
return 0;
} | a.cc:2:1: error: extended character is not valid in an identifier
2 |
| ^
a.cc:2:1: error: '\U000000a0' does not name a type
2 |
| ^
a.cc: In function 'long long int calc(int, int)':
a.cc:29:12: error: 'checked' was not declared in this scope
29 | if(checked[state][now]) return dp[state][now];
| ^~~~~~~
a.cc:30:9: error: 'checked' was not declared in this scope
30 | checked[state][now]=1;
| ^~~~~~~
|
s960580856 | p03661 | C++ | #include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <windows.h>
using namespace std;
/**==Info==
*Program:3
*Problem:Fennec VS. Snuke
*Date:2017-7-16
*Algorithm:BFS*/
int df[100005];
int ds[100005];
pair<int,int> roads[100005];
queue<int> q;
vector<int> nei[100005];
int main(){
int n;
cin>>n;
for(int i=0;i<n-1;i++){
int a,b;
cin>>a>>b;
a--;b--;
roads[i]=(a>b?make_pair(b,a):make_pair(a,b));
nei[a].push_back(b);
nei[b].push_back(a);
}
// for(int i=0;i<n;i++){
// for(int j=0;j<nei[i].size();j++){
// cout<<nei[i][j]<<" ";
// }
// cout<<endl;
// }
//First BFS
q.push(0);
df[0]=1;
while(!q.empty()){
int last=q.front();
q.pop();
//cout<<last<<" "<<nei[last].size();
for(int i=0;i<nei[last].size();i++){
if(df[nei[last][i]]==0){
df[nei[last][i]]=df[last]+1;
q.push(nei[last][i]);
}
}
}
// for(int i=0;i<n;i++){
// cout<<df[i]<<" ";
// }
//Second BFS
q.push(n-1);
ds[n-1]=1;
while(!q.empty()){
int last=q.front();
q.pop();
for(int i=0;i<nei[last].size();i++){
if(ds[nei[last][i]]==0){
ds[nei[last][i]]=ds[last]+1;
q.push(nei[last][i]);
}
}
}
//
// for(int i=0;i<n;i++){
// cout<<df[i]<<" ";
// }
// cout<<endl;
// for(int i=0;i<n;i++){
// cout<<ds[i]<<" ";
// }
cout<<endl;
int fwin=0,swin=0;
for(int i=0;i<n;i++){
if(df[i]<=ds[i])fwin++;else swin++;
}
cout<<(fwin>swin?"Fennec":"Snuke");
return 0;
}
| a.cc:21:10: fatal error: windows.h: No such file or directory
21 | #include <windows.h>
| ^~~~~~~~~~~
compilation terminated.
|
s391646860 | p03661 | C++ | #include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <cmath>
using namespace std;
const int len = 200010;
int a[len],n,k;
int main() {
cin >> n;
long long sum = 0;
for (int i=1;i<=n;i++) {
cin >> a[i];
sum += a[i];
}
long long mn = 1e18;
long long s = 0;
if (n == 2) {
cout << abs(a[1]-a[2]) << endl;
}
else {
for (int i=1;i<n;i++) {
s += a[i];
sum -= a[i];
mn = min(mn,abs(s-sum));
}
cout << mn << endl;
}
return 0;
} | a.cc:13:1: error: extended character is not valid in an identifier
13 |
| ^
a.cc:15:1: error: extended character is not valid in an identifier
15 |
| ^
a.cc:18:1: error: extended character is not valid in an identifier
18 |
| ^
a.cc:13:1: error: '\U000000a0' does not name a type
13 |
| ^
a.cc:15:1: error: '\U000000a0' does not name a type
15 |
| ^
a.cc:17:7: error: 'len' was not declared in this scope
17 | int a[len],n,k;
| ^~~
a.cc:18:1: error: '\U000000a0' does not name a type
18 |
| ^
|
s674079362 | p03661 | C++ | #include <iostream>
#define ll long long
#define MAXN 200001
int n;
int data[MAXN];
ll l = 0,r = 0;
ll labs(ll a){
return a>0 ? a : -a;
}
ll lmin(ll a,ll b){
return a>b ? a : b;
}
int main(){
cin >> n;
for(int i = 1;i <= n;i++){
int x;
cin >> x;
data[i] = x;
r += (ll)x;
}
ll ans = r;
for(int i = 1;i <= n;i++){
l += data[i]; r -= data[i];
ans = lmin(ans,labs(l-r));
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:18:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
18 | cin >> n;
| ^~~
| std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:32:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
32 | cout << ans << endl;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:32:24: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
32 | cout << ans << endl;
| ^~~~
| std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
|
s298899756 | p03661 | C++ | #include <iostream>
#define ll long long
#define MAXN 200001
int n;
int data[MAXN];
ll l = 0,r = 0;
ll labs(ll a){
return a>0 ? a : -a;
}
int main(){
scanf("%d",&n);
for(int i = 1;i <= n;i++){
int x;
scanf("%d",&x);
data[i] = x;
r += (ll)x;
}
ll ans = r;
for(int i = 1;i <= n;i++){
l += data[i]; r -= data[i];
ans = min(ans,labs(l-r));
}
printf("%d\n",ans);
return 0;
} | a.cc: In function 'int main()':
a.cc:26:23: error: 'min' was not declared in this scope; did you mean 'std::min'?
26 | ans = min(ans,labs(l-r));
| ^~~
| std::min
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:281:5: note: 'std::min' declared here
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
|
s402161272 | p03661 | C++ | #include <bits/stdc++.h>
using namespace std;
int64_t solve (vector<int64_t> const & nums) {
int64_t sum = accumulate (nums.begin (), nums.end (), 0);
int64_t ans = INT64_MAX;
int64_t parsum = 0;
for (int i = 0; i < nums.size () - 1; ++i) {
parsum += nums[i];
ans = min (ans, abs(sum - 2 * parsum));
}
return ans;
}
int main () {
cin >> n;
std::vector<int64_t> nums (n);
for (auto & num : nums)
cin >> num;
cout << solve (nums) << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:19:12: error: 'n' was not declared in this scope; did you mean 'yn'?
19 | cin >> n;
| ^
| yn
|
s924802612 | p03661 | C++ | #include <bits/stdc++.h>
using namespace std;
auto solve (vector<int64_t> const & nums) {
int64_t sum = accumulate (nums.begin (), nums.end (), 0);
int64_t ans = INT64_MAX;
int64_t parsum = 0;
for (int i = 0; i < nums.size () - 1; ++i) {
parsum += nums[i];
ans = min (ans, abs(sum - 2 * parsum));
}
return ans;
}
int main () {
cin >> n;
std::vector<int64_t> nums (n);
for (auto & num : nums)
cin >> num;
cout << solve (nums) << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:19:12: error: 'n' was not declared in this scope; did you mean 'yn'?
19 | cin >> n;
| ^
| yn
|
s031280009 | p03661 | C++ | #include <iostream> #include <cstdlib> #include <algorithm> using namespace std; int main() { int n, a[200005]; long long min_ = int(1e18), sum[200005]; cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i]; if (i > 0) sum[i] += sum[i - 1] + a[i]; else sum[i] = a[i]; } for (int i = 0; i < n-1; ++i ) { min_ = min(min_, abs(sum[i] - (sum[n-1] - sum[i]))); } cout << min_ << endl; return 0; } | a.cc:1:118: warning: extra tokens at end of #include directive
1 | #include <iostream> #include <cstdlib> #include <algorithm> using namespace std; int main() { int n, a[200005]; long long min_ = int(1e18), sum[200005]; cin >> n; for (int i = 0; i < n; ++i) { cin >> a[i]; if (i > 0) sum[i] += sum[i - 1] + a[i]; else sum[i] = a[i]; } for (int i = 0; i < n-1; ++i ) { min_ = min(min_, abs(sum[i] - (sum[n-1] - sum[i]))); } cout << min_ << endl; return 0; }
| ^
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
|
s631856254 | p03661 | C | #include<stdio.h>
#include <stdlib.h>
int main(){
int a;
scanf("%d",&a);
int k[a];
for(int i = 0; i < a; i++){
scanf("%d",&k[i]);
}
for(i=a;i>=0;i=i-1){
for(int ii=0;ii<i;ii=ii+1){
int tmp;
if(k[a] > k[i]){
tmp = k[a];
k[a] = k[i];
k[i] = tmp;
}
}
}
int kf[a];
for(int iii=0;iii<a;iii++){
int f,h;
for(int i4=0;i4<iii;i4++){
f = f + k[i4];
}
for(int i4=a;i4>iii;i4--){
h = h + k[i4];
}
k[iii] = abs(f-h);
}
int minval = kf[0];
for(int i = 0; i < a; i++){
if(minval > kf[i]){
minval = kf[i];
}
}
printf("%d",minval);
} | main.c: In function 'main':
main.c:10:5: error: 'i' undeclared (first use in this function)
10 | for(i=a;i>=0;i=i-1){
| ^
main.c:10:5: note: each undeclared identifier is reported only once for each function it appears in
|
s281665115 | p03661 | C | #include<stdio.h>
#include <stdlib.h>
int main(){
int a;
scanf("%d",&a);
int k[a];
for(int i = 0; i < a; i++){
scanf("%d",k[i]);
}
for(i=a;i>=0;i=i-1){
for(int ii=0;ii<i;ii=ii+1){
int tmp;
if(k[a] > k[i]){
tmp = k[a];
k[a] = k[i];
k[i] = tmp;
}
}
}
int kf[a];
for(int iii=0;iii<a;iii++){
int f,h;
for(int i4=0;i4<iii;i4++){
f = f + k[i4];
}
for(int i4=a;i4>iii;i4--){
h = h + k[i4];
}
k[iii] = abs(f-h);
}
int minval = kf[0];
for(i = 0; i < a; i++){
if(minval > kf[i]){
minval = kf[i];
}
}
printf("%d",minval);
} | main.c: In function 'main':
main.c:10:5: error: 'i' undeclared (first use in this function)
10 | for(i=a;i>=0;i=i-1){
| ^
main.c:10:5: note: each undeclared identifier is reported only once for each function it appears in
|
s081846657 | p03661 | C | #include<stdio.h>
#include <stdlib.h>
int main(){
int a;
scanf("%d",&a);
int k[a];
for(int i = 0; i < a; i++){
scanf("%d",k[i]);
}
for(i=a;i>=0;i=i-1){
for(int ii=0;ii<i;ii=ii+1){
int tmp;
if(k[a] > k[i]){
tmp = k[a];
k[a] = k[i];
k[i] = tmp;
}
}
}
int kf[a];
for(int iii=0;iii<a;iii++){
int f,h;
for(int i4=0;i4<iii;i4++){
f = f + k[i4];
}
for(i4=a;i4>iii;i4--){
h = h + k[i4];
}
k[iii] = abs(f-h);
}
int minval = kf[0];
for(i = 0; i < a; i++){
if(maxval > kf[i]){
minval = kf[i];
}
}
printf("%d",minval);
} | main.c: In function 'main':
main.c:10:5: error: 'i' undeclared (first use in this function)
10 | for(i=a;i>=0;i=i-1){
| ^
main.c:10:5: note: each undeclared identifier is reported only once for each function it appears in
main.c:27:5: error: 'i4' undeclared (first use in this function)
27 | for(i4=a;i4>iii;i4--){
| ^~
main.c:37:12: error: 'maxval' undeclared (first use in this function); did you mean 'minval'?
37 | if(maxval > kf[i]){
| ^~~~~~
| minval
|
s556057208 | p03661 | C++ | #include<stdio.h>
int main(){
int a;
scanf("%d",&a);
int k[a]
for(int i = 0; i < a; i++){
scanf("%d",k[i]);
}
for(i=a;i>=0;i=i-1){
for(ii=0;ii<i;ii=ii+1){
int tmp;
if(k[a] > k[i]){
tmp = k[a];
k[a] = k[i];
k[i] = tmp;
}
}
}
int kf[a];
for(iii=0;iii<a;iii++){
int f,h;
for(i4=0;i4<iii;i4++){
f = f + k[i4];
}
for(i4=a;i4>iii;i4--){
h = h + k[i4];
}
k[iii] = abs(f-h);
}
int minval = kf[0];
for(i = 0; i < a; i++){
if(maxval > kf[i]){
minval = kf[i];
}
}
printf("%d",minval);
}
| a.cc: In function 'int main()':
a.cc:6:1: error: expected initializer before 'for'
6 | for(int i = 0; i < a; i++){
| ^~~
a.cc:6:16: error: 'i' was not declared in this scope
6 | for(int i = 0; i < a; i++){
| ^
a.cc:10:5: error: 'ii' was not declared in this scope
10 | for(ii=0;ii<i;ii=ii+1){
| ^~
a.cc:13:12: error: 'k' was not declared in this scope
13 | if(k[a] > k[i]){
| ^
a.cc:21:5: error: 'iii' was not declared in this scope
21 | for(iii=0;iii<a;iii++){
| ^~~
a.cc:23:5: error: 'i4' was not declared in this scope
23 | for(i4=0;i4<iii;i4++){
| ^~
a.cc:24:9: error: 'k' was not declared in this scope
24 | f = f + k[i4];
| ^
a.cc:26:5: error: 'i4' was not declared in this scope
26 | for(i4=a;i4>iii;i4--){
| ^~
a.cc:27:9: error: 'k' was not declared in this scope
27 | h = h + k[i4];
| ^
a.cc:29:1: error: 'k' was not declared in this scope
29 | k[iii] = abs(f-h);
| ^
a.cc:29:10: error: 'abs' was not declared in this scope
29 | k[iii] = abs(f-h);
| ^~~
a.cc:36:12: error: 'maxval' was not declared in this scope; did you mean 'minval'?
36 | if(maxval > kf[i]){
| ^~~~~~
| minval
|
s388966947 | p03661 | Java | This is an interactive task. | Main.java:1: error: class, interface, enum, or record expected
This is an interactive task.
^
1 error
|
s199252740 | p03661 | C++ | #include<iostream>
#include<vector>
#include<queue>
#include<set>
using namespace std;
const int N = 1e5 + 10;
typedef long long ll;
int c[N];
int vis[N], id;
int d[2][N];
vector<vector<int> > v;
void dfs(int u, int cost) {
d[id][u] = cost;
vis[u] = id;
for (int i = 0; i < v[u].size(); ++i) {
int next = v[u][i];
if (vis[next] < id)
dfs(next, cost + 1);
}
}
int main() {
memset(vis, -1, sizeof vis);
int n;
cin >> n;
v.resize(n);
for (int i = 0; i < n - 1; ++i) {
int a, b;
cin >> a >> b;
--a;
--b;
v[a].push_back(b);
v[b].push_back(a);
}
dfs(0, 0); ++id; dfs(n - 1, 0);
int a = 0;
int b = 0;
int path = d[0][n - 1];
for (int i = 1; i < n - 1; ++i) {
int cost1 = d[0][i];//from 0 to i
int cost2 = d[1][i];//from n-1 to i
if (cost1 < cost2)
++a;
else if (cost1 > cost2)
++b;
else {
if (path % 2 == 0)
++a;
else
++b;
}
}
if (a > b)
cout << "Fennec";
else
cout << "Snuke";
cout << endl;
} | a.cc: In function 'int main()':
a.cc:22:9: error: 'memset' was not declared in this scope
22 | memset(vis, -1, sizeof vis);
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include<set>
+++ |+#include <cstring>
5 | using namespace std;
|
s107686226 | p03661 | C++ |
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
auto& in = std::cin;
auto& out = std::cout;
int64_t N;
std::vector<int64_t> graph[200000];
bool used[200000] = {};
bool seted[200000] = {};
template<typename T>
void fill_all(T& arr, const T& v) {
arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
for (auto& i : arr) { fill_all(i, v); }
}
//0->N-1パス
bool func_1(int64_t i)
{
used[i] = true;
if (i == N - 1) { return true; }
for (auto& nex : graph[i])
{
if (used[nex] == false)
{
if (func_1(nex)) { return true; }
}
}
used[i] = false;
return false;
}
int64_t count(int64_t i, int64_t parent)
{
int64_t sum = 1;
for (auto& nex : graph[i])
{
if (nex != parent)
{
sum += count(nex,i);
}
}
return sum;
}
int64_t main()
{
using std::endl;
in.sync_with_stdio(false);
out.sync_with_stdio(false);
in.tie(nullptr);
out.tie(nullptr);
in >> N;
for (int64_t i = 0; i < N-1; ++i)
{
int64_t a,b;
in >> a >> b; --a; --b;
graph[a].push_back(b);
graph[b].push_back(a);
}
func_1(0);
seted[0] = true;
seted[N - 1] = true;
int64_t first_num = 0;//1
int64_t fpos = 0;
int64_t second_num = 0;
int64_t spos = N-1;
for (auto& v : graph[fpos]) {
if (!used[v]) {
first_num += count(v, fpos);
}
}
for (auto& v : graph[spos]) {
if (!used[v]) {
second_num += count(v, spos);
}
}
bool updated = true;
while(updated)
{
updated = false;
for (auto& v : graph[fpos]) {
if (used[v]) {
if (seted[v]) { break; }
updated = true;
seted[v] = true;
fpos = v;
++first_num;
break;
}
}
if (!updated) { break; }
for (auto& v : graph[fpos]) {
if (!used[v]) {
first_num += count(v, fpos);
}
}
updated = false;
for (auto& v : graph[spos]) {
if (used[v]) {
if (seted[v]) { break; }
updated = true;
seted[v] = true;
spos = v;
++second_num;
break;
}
}
if (!updated) { break; }
for (auto& v : graph[spos]) {
if (!used[v]) {
second_num += count(v, spos);
}
}
}
if (first_num > second_num) {
out << "Fennec" << endl;
}
else if (second_num > first_num) {
out << "Snuke" << endl;
}
else {
out << "Snuke" << endl;
}
return 0;
}
#endif
| a.cc:70:1: error: '::main' must return 'int'
70 | int64_t main()
| ^~~~~~~
|
s306257017 | p03661 | Java | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int N = scanner.nextInt();
long[] a = new int[N];
long y = 0;
a[0] = scanner.nextInt();
for(int i = 1; i < N; i++) {
a[i] = scanner.nextInt();
y += a[i];
}
long x = a[0];
long min = Math.abs(x - y);
for(int i = 1; i < N - 1; i++) {
x += a[i];
y -= a[i];
long calc = Math.abs(x - y);
if(min > calc) {
min = calc;
}
}
System.out.println(min);
}
} | Main.java:10: error: incompatible types: int[] cannot be converted to long[]
long[] a = new int[N];
^
1 error
|
s758560853 | p03661 | Java | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int N = scanner.nextInt();
int[] a = new int[N];
long y = 0;
a[0] = scanner.nextInt();
for(int i = 1; i < N; i++) {
a[i] = scanner.nextInt();
y += a[i];
}
long x = a[0];
int min = Math.abs(x - y);
for(int i = 1; i < N - 1; i++) {
x += a[i];
y -= a[i];
int calc = Math.abs(x - y);
if(min > calc) {
min = calc;
}
}
System.out.println(min);
}
} | Main.java:20: error: incompatible types: possible lossy conversion from long to int
int min = Math.abs(x - y);
^
Main.java:24: error: incompatible types: possible lossy conversion from long to int
int calc = Math.abs(x - y);
^
2 errors
|
s277992723 | p03661 | C++ | #include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<cstring>
#define N 200005
#define M 1000000005
using namespace std;
int a[N],b[M],n,sum,m;
int main(){
std::ios::sync_with_stdio(false);
cin>>n;m=(int)1e9+5;
for (int i=1;i<=n;i++) {cin>>a[i],m=min(m,a[i])};
if (m<0) for (int i=1;i<=n;i++) a[i]+=m;
for (int i=1;i<=n;i++) sum+=a[i];
for (int i=1;i<=n;i++)
for (int j=sum/2;j>=a[i];j--)
if (b[j]<b[j-a[i]]+a[i]) b[j]=b[j-a[i]]+a[i];
cout<<sum-b[sum/2]*2;
return 0;
} | a.cc: In function 'int main()':
a.cc:27:57: error: expected ';' before '}' token
27 | for (int i=1;i<=n;i++) {cin>>a[i],m=min(m,a[i])};
| ^
| ;
|
s882277523 | p03661 | C++ | #include <iostream>
#include <vector>
#include <math>
using namespace std;
int main(void){
int N, a;
long long sum = 0;
cin >> N;
vector<int> vec(N);
vector<long long> vec_sum(N, 0);
for(int i = 0; i < N; i++)
{
cin >> a;
vec[i] = a;
sum += a;
vec_sum[i] = sum;
}
int min = abs(sum - 2*vec_sum[1]);
for(int i = 1; i < N - 1; i++)
{
if(abs(sum - 2*vec_sum[i]) == 0)
{
cout << abs(sum - 2*vec_sum[i]) << endl;;
break;
return 0;
}
if(abs(sum - 2*vec_sum[i]) < min)
{
min = abs(sum - 2*vec_sum[i]) ;
}
}
cout << min << endl;
return 0;
} | a.cc:3:10: fatal error: math: No such file or directory
3 | #include <math>
| ^~~~~~
compilation terminated.
|
s633032638 | p03661 | C++ | //#define MYDEBUG
#include <bits/stdc++.h>
#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
#define EPS = 1e-14;
using std::vector;
using std::cout;
using std::cin;
using std::endl;
using std::max;
using std::min;
using std::swap;
using std::string;
using std::fill;
using std::pair;
using std::sort;
using std::reverse;
using std::pair;
using std::greater;
using std::priority_queue;
using std::ostream;
template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
for (size_t i = 0; i < v.size(); ++i) {
out << v[i] << endl;
}
return out;
}
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
out << "[";
size_t last = v.size() - 1;
for (size_t i = 0; i < v.size(); ++i) {
out << v[i];
if (i != last) {
out << ",";
}
}
out << "]";
return out;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& p) {
out << "(" << p.first << ", " << p.second << ")";
return out;
}
static const ll MAX_N = 100010 * 2;
static const ll INF = 1000000000000000000;
int N;
ll a[MAX_N], sum[MAX_N];
void solve() {
cin >> N;
a[0] = 0;
sum[0] = 0;
REP(i,1,N)
{
cin >> a[i];
sum[i] = sum[i - 1] + a[i];
}
//x: sum[k] - sum[1-1] = sum[k] - sum[0]
//y: sum[n] - sum[k+1-1] = sum[n] - sum[k]
//k=1; k<=n-1; ++k
ll ans = INF;
for (int k = 1; k <= N - 1; ++k) {
ll x = sum[k] - sum[0];
ll y = sum[N] - sum[k];
ans = min(ans, abs(x - y));
}
cout << ans << endl;
}
int main() {
solve();
}
| a.cc: In function 'void solve()':
a.cc:87:14: error: no matching function for call to 'min(long long int&, int)'
87 | ans = min(ans, abs(x - y));
| ~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc: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: template argument deduction/substitution failed:
a.cc:87:14: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
87 | ans = min(ans, abs(x - y));
| ~~~^~~~~~~~~~~~~~~~~
/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
In file included from /usr/include/c++/14/algorithm:60:
/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
/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:87:14: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
87 | ans = min(ans, abs(x - y));
| ~~~^~~~~~~~~~~~~~~~~
|
s247727664 | p03661 | Java | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int N = scanner.nextInt();
int[] a = new int[N];
int sum = 0;
a[0] = scanner.nextInt();
for(int i = 1; i < N; i++) {
a[i] = scanner.nextInt();
sum += a[i];
}
int x = a[0];
int min = Math.abs(x - sum);
for(int i = 1; i < N; i++) {
int calc = Math.abs(x - sum);
if(calc > Math.abs(x + 2 * a[i] - sum)) {
x += a[i];
sum -= a[i];
} else {
if(min > calc) {
min = calc;
}
}
}
System.out.println(calc);
}
} | Main.java:32: error: cannot find symbol
System.out.println(calc);
^
symbol: variable calc
location: class Main
1 error
|
s594628585 | p03661 | C++ | #include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int main()
{
int n,a[200000],i,j,f;
ll l,r,ans;
l=r=ans=0;
scanf("%d",&n);
for(i=1;i<=n;i++)
{scanf("%d",&a[i]);
a[i]+=1000000000;}
sort(a+1,a+n+1);
l=b[n];
r=b[n-1];
for(i=n-2;i>=1;i--)
{
if(l>r)
r+=a[i];
else
l+=a[i];
}
if(l>r)
ans=l-r;
else
ans=r-l;
printf("%lld",ans);
return 0;
} | a.cc: In function 'int main()':
a.cc:18:7: error: 'b' was not declared in this scope
18 | l=b[n];
| ^
|
s485448868 | p03661 | C++ | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author wh1t3_r0s3
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(outputStream);
TaskC solver = new TaskC();
solver.solve(1, in, out);
out.close();
}
static class TaskC {
public void solve(int testNumber, InputReader in, PrintWriter out) {
int n = in.nextInt();
long[] a = new long[n + 1];
long[] p = new long[n + 1];
for (int i = 1; i <= n; i++) {
a[i] = in.nextInt();
}
p[0] = 0;
for (int i = 1; i <= n; i++) {
p[i] = p[i - 1] + a[i];
}
long Min = 1000000007;
for (int i = 1; i < n; i++) {
long y = p[n] - p[i];
long x = p[i] - p[0];
long diff = Math.abs(x - y);
Min = Math.min(Min, diff);
}
out.println(Min);
}
}
static class InputReader {
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 32768);
tokenizer = null;
}
public String next() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public int nextInt() {
return Integer.parseInt(next());
}
}
}
| a.cc:1:1: error: 'import' does not name a type
1 | import java.io.OutputStream;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
2 | import java.io.IOException;
| ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
3 | import java.io.InputStream;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
4 | import java.io.PrintWriter;
| ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
5 | import java.util.StringTokenizer;
| ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: 'import' does not name a type
6 | import java.io.IOException;
| ^~~~~~
a.cc:6:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: 'import' does not name a type
7 | import java.io.BufferedReader;
| ^~~~~~
a.cc:7:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:8:1: error: 'import' does not name a type
8 | import java.io.InputStreamReader;
| ^~~~~~
a.cc:8:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:9:1: error: 'import' does not name a type
9 | import java.io.InputStream;
| ^~~~~~
a.cc:9:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:17:1: error: expected unqualified-id before 'public'
17 | public class Main {
| ^~~~~~
|
s041126362 | p03661 | C++ | #include <bits/stdc++.h>
using namespace std;
unsigned long long arr[200200], sum[200200];
unsigned long long n, ans = 0x7ffffffffffffffULL;
int main() {
scanf("%llu", &n);
for (int i = 1; i <= n; i++) {
scanf("%llu", &arr[i]);
sum[i] = sum[i - 1] + arr[i];
}
for (int i = 2; i <= n; i++) {
ans = min(ans, abs((sum[i - 1] << 1) - sum[n]));
}
printf("%llu", ans);
} | a.cc: In function 'int main()':
a.cc:14:35: error: call of overloaded 'abs(long long unsigned int)' is ambiguous
14 | ans = min(ans, abs((sum[i - 1] << 1) - sum[n]));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:42,
from a.cc:1:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
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: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:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/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:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/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:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
|
s861062711 | p03661 | C++ | #include <bits/stdc++.h>
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))
using namespace std;
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
// Problem Specific Parameter:
int main(void){
int n;
cin >> n;
vector<ll> a(n);
rep(i,n) cin >> a[i];
const ll sum = accumulate(begin(a),end(a),0LL);
ll ans = 1LL << 60;
ll cur = 0LL;
rep(i,n){
cur += a[i];
if(i==n-1) break;
ll alt = sum - cur;
chmin(ans,abs(cur-alt));
}i
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:52:10: error: 'i' was not declared in this scope
52 | }i
| ^
|
s815469907 | p03661 | C++ | #include<iostream>
using namespace std;
long long abs(long long x)
{
if(x<0)
return -1*x;
return x;
}
long long a[200005];
int main()
{
int n;
cin>>n;
long long sum=0;
for(int i=0;i<n;i++)
{
cin>>a[i];
sum+=a[i];
}
long long pr=a[0],ans=abs(sum-pr-pr);
for(int i=1;i<n-1;i++)
{
pr+=a[i];
ans=min(ans,abs(sum-2*pr));
}
cout<<ans;
return 0;
}
| a.cc: In function 'int main()':
a.cc:23:30: error: call of overloaded 'abs(long long int)' is ambiguous
23 | long long pr=a[0],ans=abs(sum-pr-pr);
| ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
from /usr/include/c++/14/ext/string_conversions.h:43,
from /usr/include/c++/14/bits/basic_string.h:4154,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:4:11: note: candidate: 'long long int abs(long long int)'
4 | long long abs(long long x)
| ^~~
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: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:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/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:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/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:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
a.cc:27:24: error: call of overloaded 'abs(long long int)' is ambiguous
27 | ans=min(ans,abs(sum-2*pr));
| ~~~^~~~~~~~~~
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:4:11: note: candidate: 'long long int abs(long long int)'
4 | long long abs(long long x)
| ^~~
/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: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:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/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:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/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:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
|
s251746354 | p03661 | C++ | #include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;
const long long maxv=1e14;
int dp[maxv];
int a[200010];
int main()
{
int n,sum=0,ans;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
sum+=a[i];
}
for(int i=0;i<n;i++)
{
for(int v=sum/2;v>=a[i];v--)
{
dp[v]=max(dp[v],dp[v-a[i]]+a[i]);
}
}
ans=abs((sum-dp[sum/2])-dp[sum/2]);
printf("%d",ans);
return 0;
}
| /tmp/ccDr0pSA.o: in function `main':
a.cc:(.text+0x43): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccDr0pSA.o
a.cc:(.text+0x71): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccDr0pSA.o
a.cc:(.text+0xb7): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccDr0pSA.o
a.cc:(.text+0xe8): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccDr0pSA.o
a.cc:(.text+0x148): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccDr0pSA.o
collect2: error: ld returned 1 exit status
|
s523038509 | p03661 | C++ | #include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
const long long maxv=1e14;
int dp[maxv];
int a[200010];
int main()
{
int n,sum=0,ans;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
sum+=a[i];
}
for(int i=0;i<n;i++)
{
for(int v=sum/2;v>=a[i];v--)
{
dp[v]=max(dp[v],dp[v-a[i]]+a[i]);
}
}
ans=abs((sum-dp[sum/2])-dp[sum/2]);
printf("%d",ans);
return 0;
}
| /tmp/ccgdosgk.o: in function `main':
a.cc:(.text+0x43): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccgdosgk.o
a.cc:(.text+0x71): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccgdosgk.o
a.cc:(.text+0xb7): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccgdosgk.o
a.cc:(.text+0xe8): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccgdosgk.o
a.cc:(.text+0x148): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccgdosgk.o
collect2: error: ld returned 1 exit status
|
s279378648 | p03661 | C++ | #include <bits/stdc++.h>
#include <stdio.h>
using namespace std;
const long long maxv=1e14;
int dp[maxv];
int a[200010];
int main()
{
int n,sum=0,ans;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
sum+=a[i];
}
for(int i=0;i<n;i++)
{
for(int v=sum/2;v>=a[i];v--)
{
dp[v]=max(dp[v],dp[v-a[i]]+a[i]);
}
}
ans=abs((sum-dp[sum/2])-dp[sum/2]);
printf("%d",ans);
return 0;
}
| /tmp/ccIxyjAM.o: in function `main':
a.cc:(.text+0x43): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccIxyjAM.o
a.cc:(.text+0x71): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccIxyjAM.o
a.cc:(.text+0xb7): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccIxyjAM.o
a.cc:(.text+0xe8): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccIxyjAM.o
a.cc:(.text+0x148): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccIxyjAM.o
collect2: error: ld returned 1 exit status
|
s019180007 | p03661 | C++ | #include<iostream>
#include<fstream>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<cmath>
#include<ctime>
#include<locale>
using namespace std;
long long a[100001];
int main()
{
long n;
cin>>n;
long long z=20000000000;
long long s=0;
for(long i=0;i<n;i++)
{
//long long x;
scanf("%ld",&a[i]);
//q.push(x);
s+=a[i];
}
long long x=0;
for(long i=0;i<n;i++)
{
x+=a[i];
z=min(z,abs(s-x*2))
}
cout<<z;
return 0;
}
| a.cc: In function 'int main()':
a.cc:33:28: error: expected ';' before '}' token
33 | z=min(z,abs(s-x*2))
| ^
| ;
34 | }
| ~
|
s639260360 | p03661 | C++ | #include <bits/stdc++.h>
using namespace std;
const long long maxv=1e14;
int dp[maxv];
int a[200010];
int main()
{
int n,sum=0,ans;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
sum+=a[i];
}
for(int i=0;i<n;i++)
{
for(int v=sum/2;v>=a[i];v--)
{
dp[v]=max(dp[v],dp[v-a[i]]+a[i]);
}
}
ans=abs((sum-dp[sum/2])-dp[sum/2]);
printf("%d",ans);
return 0;
}
| /tmp/cc73SCKK.o: in function `main':
a.cc:(.text+0x43): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/cc73SCKK.o
a.cc:(.text+0x71): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/cc73SCKK.o
a.cc:(.text+0xb7): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/cc73SCKK.o
a.cc:(.text+0xe8): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/cc73SCKK.o
a.cc:(.text+0x148): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/cc73SCKK.o
collect2: error: ld returned 1 exit status
|
s280450262 | p03661 | C | #include <stdio.h>
#include <stdlib.h>
int main (void){
int N;
scanf ("%d", &N);
int a[N];
long long sum = 0, min = 0;
for (int i=0; i<N; i++){
scanf ("%d", &a[i]);
sum += a[i];
min += abs (a[i]);
}
//FR
long long x = 0;
for (int i=1; i<N-2; i++){
x += a[j];
if (abs (2*x-sum)<min){
min = abs (2*x-sum);
}
}
printf ("%lld\n", min);
return 0;
} | main.c: In function 'main':
main.c:17:20: error: 'j' undeclared (first use in this function)
17 | x += a[j];
| ^
main.c:17:20: note: each undeclared identifier is reported only once for each function it appears in
|
s755795855 | p03661 | C++ | #include <cstdio>
#include <iostream>
#define LL long long
using namespace std;
inline LL read(){
LL ret=0,p=1;
char ch=getchar();
for (;!isdigit(ch);ch=getchar()) if (ch=='-') p=-1;
for (;isdigit(ch);ch=getchar()) ret=ret*10+ch-'0';
return ret*p;
}
int n;
LL a[200000+3],s[200000+3];
LL abs(LL x){
if (x<0) return -x;return x;
}
LL min(LL a,LL b){
if (a<b) return a;return b;
}
int main(){
n=read();s[0]=0;
for (int i=1;i<=n;i++) a[i]=read(),s[i]=s[i-1]+a[i];
LL ans=1e9;ans*=ans;
for (int i=1;i<n;i++){
ans=min(ans,abs(s[6]-s[i]-s[i]));
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:25:32: error: call of overloaded 'abs(long long int)' is ambiguous
25 | ans=min(ans,abs(s[6]-s[i]-s[i]));
| ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
from /usr/include/c++/14/ext/string_conversions.h:43,
from /usr/include/c++/14/bits/basic_string.h:4154,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:14:4: note: candidate: 'long long int abs(long long int)'
14 | LL abs(LL x){
| ^~~
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: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:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/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:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/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:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
|
s937286926 | p03661 | C++ | #include<iostream>
using namespace std;
int main()
{
int n;
cin >> n;
int a[n];
int sum=0;
for(int i=0;i<n;i++){
cin >> a[i];
sum =sum+a[i];
}
if(n==2){
int k=abs(a[0]-a[1]);
cout << k;
}
else{
int sum2=0;
int ans1;
int ans2;
for(int i=0;i<n;i++){
sum2=sum2+a[i];
int sub=sum-sum2;
if(sub < sum2){
ans1=abs(sum2-sub);
sum2=sum2-a[i];
sub =sub+a[i];
ans2=abs(sum2-sub);
break;
}
if(i==n-1){
ans1=sum-a[n-1];
ans2=ans+1;
}
}
if(ans1<ans2){
cout << ans1;
}
else{
cout <<ans2;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:33:6: error: 'ans' was not declared in this scope; did you mean 'ans2'?
33 | ans2=ans+1;
| ^~~
| ans2
|
s303945344 | p03661 | C++ | include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cstdlib>
using namespace std;
int main()
{
int N;
cin >> N;
int a[200000];
int t_snk = 0, t_arai = 0;
for (int i = 0; i < N; i++) {
cin >> a[i];
}
t_snk = a[0];
for (int i = 1; i < N; i++) {
t_arai += a[i];
}
vector<long long int> diff;
diff.push_back(abs(t_snk - t_arai));
for (int i = 1; i < N-1; i++) {
t_snk += a[i];
t_arai -= a[i];
diff.push_back(abs(t_snk - t_arai));
}
int min = *min_element(diff.begin(), diff.end());
cout << min << endl;
return 0;
} | a.cc:1:1: error: 'include' does not name a type
1 | include<iostream>
| ^~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:62,
from /usr/include/c++/14/vector:62,
from a.cc:2:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
164 | __is_null_pointer(std::nullptr_t)
| ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
159 | __is_null_pointer(_Type)
| ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'
164 | __is_null_pointer(std::nullptr_t)
| ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/type_traits:295:27: error: 'size_t' has not been declared
295 | template <typename _Tp, size_t = sizeof(_Tp)>
| ^~~~~~
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'
666 | struct is_null_pointer<std::nullptr_t>
| ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
666 | struct is_null_pointer<std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
670 | struct is_null_pointer<const std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
674 | struct is_null_pointer<volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
678 | struct is_null_pointer<const volatile std::nullptr_t>
| ^
/usr/include/c++/14/type_traits:984:26: error: 'size_t' has not been declared
984 | template<typename _Tp, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope
985 | struct __is_array_known_bounds<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid
985 | struct __is_array_known_bounds<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
1438 | : public integral_constant<std::size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
1440 | template<typename _Tp, std::size_t _Size>
| ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
1441 | struct rank<_Tp[_Size]>
| ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
1441 | struct rank<_Tp[_Size]>
| ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1451:32: error: 'size_t' was not declared in this scope
1451 | : public integral_constant<size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
63 | #include <bits/version.h>
+++ |+#include <cstddef>
64 |
/usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid
1451 | : public integral_constant<size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared
1453 | template<typename _Tp, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope
1454 | struct extent<_Tp[_Size], 0>
| ^~~~~
/usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid
1454 | struct extent<_Tp[_Size], 0>
| ^
/usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope
1455 | : public integral_constant<size_t, _Size> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope
1455 | : public integral_constant<size_t, _Size> { };
| ^~~~~
/usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid
1455 | : public integral_constant<size_t, _Size> { };
| ^
/usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid
/usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared
1457 | template<typename _Tp, unsigned _Uint, size_t _Size>
| ^~~~~~
/usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope
1458 | struct extent<_Tp[_Size], _Uint>
| ^~~~~
/usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid
1458 | struct extent<_Tp[_Size], _Uint>
| ^
/usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope
1463 | : public integral_constant<size_t, 0> { };
| ^~~~~~
/usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid
1463 | : public integral_constant<size_t, 0> { };
| ^
/usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type
1857 | { static constexpr size_t __size = sizeof(_Tp); };
| ^~~~~~
/usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared
1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
| ^~~~~~
/usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope
1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)>
| ^~~
/usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp'
1860 | struct __select;
| ^~~~~~~~
/usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared
1862 | template<size_t _Sz, typename _Uint, typename... _UInts>
| ^~~~~~
/usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope
1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true>
| ^~~
/usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid
1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true>
| ^
/usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared
1866 | template<size_t _Sz, typename _Uint, typename... _UInts>
| ^~~~~~
/usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope
1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false>
| ^~~
/usr/include/c++/14/type_traits:1867:58: error: template argument 1 is invalid
1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false>
| |
s932236491 | p03661 | Java | import java.io.*;
import java.util.Locale;
import java.util.StringTokenizer;
public class Bob {
String filename = "cubes";//filename here, System.in/out if no file
FastScanner in;
PrintWriter out;
void solve() {
int n = in.nextInt();
long[] m = new long[n];
long[] p = new long[n];
long[] s = new long[n];
for (int i = 0; i < n; i++) m[i] = in.nextInt();
p[0] = m[0];
for (int i = 1; i < n; i++) p[i] = p[i - 1] + m[i];
s[n - 1] = m[n - 1];
for (int i = n - 2; i >= 0; i--) {
s[i] = m[i] + s[i + 1];
}
long ans = Integer.MAX_VALUE;
for(int i=1;i<n;i++){
ans=Math.min(ans,Math.abs(p[i-1]-s[i]));
}
out.println(ans);
}
void run() throws IOException {
InputStream input = System.in;
OutputStream output = System.out;
try {
File f = new File(filename + ".in");
if (f.exists() && f.canRead()) {
input = new FileInputStream(f);
output = new FileOutputStream(filename + ".out");
}
} catch (IOException e) {
}
in = new FastScanner(input);
out = new PrintWriter(new BufferedOutputStream(output));
solve();
in.close();
out.close();
}
public static void main(String[] args) throws IOException {
Locale.setDefault(Locale.US);
new Bob().run();
}
class FastScanner implements Closeable {
private BufferedReader br;
private StringTokenizer tokenizer;
public FastScanner(InputStream stream) throws FileNotFoundException {
br = new BufferedReader(new InputStreamReader(stream));
}
public boolean hasNext() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
String s = br.readLine();
if (s == null) {
return false;
}
tokenizer = new StringTokenizer(s);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.hasMoreTokens();
}
public String next() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(br.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public String nextLine() {
if (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
return br.readLine();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken("\n");
}
public int nextInt() {
return Integer.parseInt(next());
}
public long nextLong() {
return Long.parseLong(next());
}
public double nextDouble() {
return Double.parseDouble(next());
}
@Override
public void close() throws IOException {
br.close();
}
}
} | Main.java:6: error: class Bob is public, should be declared in a file named Bob.java
public class Bob {
^
1 error
|
s871395535 | p03661 | C++ | int main() {
//C
int n;
cin >> n;
int* arr = new int[n];
for(int i = 0; i < n; i++) {
cin >> arr[i];
}
int min = 1000000000;
int topValue = 0;
int answer = -1;
for(int i = 0; i < n-1; i++) {
topValue+=arr[i];
int downValue = 0;
for(int j = i+1; j < n; j++) {
downValue += arr[j];
}
if(abs(topValue - downValue) <= min) {
min = abs(topValue - downValue);
//cout << min << " " << topValue << " " << downValue;
}
}
answer = min;
cout << answer;
//C END
//D
//E
//F
return 0;
} | a.cc: In function 'int main()':
a.cc:4:5: error: 'cin' was not declared in this scope
4 | cin >> n;
| ^~~
a.cc:19:12: error: 'abs' was not declared in this scope
19 | if(abs(topValue - downValue) <= min) {
| ^~~
a.cc:27:5: error: 'cout' was not declared in this scope
27 | cout << answer;
| ^~~~
|
s655663258 | p03661 | C++ | #include <iostream>
#include <algorithm>
using ll = long long int;
constexpr int MAX_N = (int)1e5 * 2, INF = (int)1e9;
int n;
ll sumx[MAX_N], sumy[MAX_N];
int main() {
std::cin >> n;
for (int i = 0; i < n; ++i) {
std::cin >> sumx[i];
sumy[i] = sumx[i];
}
for (int i = 1; i < n; ++i)
sumx[i] += sumx[i - 1];
for (int i = n - 2; i >= 0; --i)
sumy[i] += sumy[i + 1];
ll ans = INF * 2;
for (int i = 0; i < n - 1; ++i)
ans = std::min(ans, abs(sumx[i] - sumy[i + 1]));
std::cout << ans << std::endl;
system("pause");
return 0;
} | a.cc: In function 'int main()':
a.cc:29:31: error: no matching function for call to 'min(ll&, int)'
29 | ans = std::min(ans, abs(sumx[i] - sumy[i + 1]));
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:29:31: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
29 | ans = std::min(ans, abs(sumx[i] - sumy[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,
from a.cc:2:
/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:29:31: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
29 | ans = std::min(ans, abs(sumx[i] - sumy[i + 1]));
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s704981174 | p03661 | C++ | #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;
using ll = long long;
int main(){
ios_base::sync_with_stdio(false);
int n;
cin >> n;
vector<ll> a(n);
for(int i = 0; i < n; ++i){ cin >> a[i]; }
const ll total = accumulate(a.begin(), a.end(), 0ll);
ll sum = 0, answer = 1000000000000000000ll;
for(int i = 0; i + 1 < n; ++i){
sum += a[i];
const ll a = sum, b = total - sum;
answer = min(answer, llabs(a - b));
}
cout << answer << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:16:26: error: 'accumulate' was not declared in this scope
16 | const ll total = accumulate(a.begin(), a.end(), 0ll);
| ^~~~~~~~~~
|
s329460672 | p03661 | C++ | #include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <windows.h>
using namespace std;
/**==Info==
*Program:C
*Problem:Splitting Pile
*Date:2017-7-15
*Algorithm:AtCoder*/
long long a[200001];
long long sum[200001];
int main(){
int n;
cin>>n;
for(int i=0;i<n;i++){
cin>>a[i];
if(i>0){
sum[i]=sum[i-1]+a[i];
}else{
sum[i]=a[i];
}
}
long long mn=1e18;
for(int i=0;i<n-1;i++){
if(abs(sum[i]-(sum[n-1]-sum[i]))<mn) mn=abs(sum[i]-(sum[n-1]-sum[i]));
}
cout<<mn;
return 0;
}
| a.cc:21:10: fatal error: windows.h: No such file or directory
21 | #include <windows.h>
| ^~~~~~~~~~~
compilation terminated.
|
s837106493 | p03661 | C++ | #include<iostream>
#include<cmath>
#include<cstdlib>
int main(){
int N,a,count=0;
cin>>N;
int card[N];
while(cin>>a){
card[count]=a;
count++;
}
count=0;
int result[N-1][2];
for(int i=0;i<N-1;i++){
result[i][0]=0;
result[i][1]=0;
}
for(int i=0;i<N-1;i++){
for(int j=0;j<i+1;j++){
result[count][0]+=card[j];
}
for(int j=N-1;j>=i+1;j--){
result[count][1]+=card[j];
}
count++;
}
int min;
for(int i=0;i<N-1;i++){
if(i==0 || i!=0 && min>abs(result[i][0]-result[i][1])){
min=(int)abs(result[i][0]-result[i][1]);
}
}
cout<<min<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:7:1: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
7 | cin>>N;
| ^~~
| std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:36:1: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
36 | cout<<min<<endl;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:36:12: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
36 | cout<<min<<endl;
| ^~~~
| std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
|
s734313460 | p03661 | C++ | #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
int main(){
ios_base::sync_with_stdio(false);
int n;
cin >> n;
vector<ll> a(n);
for(int i = 0; i < n; ++i){ cin >> a[i]; }
const ll total = accumulate(a.begin(), a.end(), 0ll);
ll sum = 0, answer = 1000000000000000000ll;
for(int i = 0; i + 1 < n; ++i){
sum += a[i];
const ll a = sum, b = total - sum;
answer = min(answer, llabs(a - b));
}
cout << answer << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:15:26: error: 'accumulate' was not declared in this scope
15 | const ll total = accumulate(a.begin(), a.end(), 0ll);
| ^~~~~~~~~~
|
s921863172 | p03661 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long LL;
const int MAXN = 100000 + 10;
LL sum[MAXN];
int main() {
// freopen("test.txt", "r", stdin);
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%lld", &sum[i]);
sum[i] += sum[i-1];
}
LL ret = LLONG_MAX;
LL tmp;
for (int i = 1; i < n; i++) {
tmp = sum[n] - 2*sum[i];
ret = min(ret, abs(tmp));
}
cout << ret << endl;
} | a.cc: In function 'int main()':
a.cc:16:14: error: 'LLONG_MAX' was not declared in this scope
16 | 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 <vector>
+++ |+#include <climits>
4 | using namespace std;
|
s958345936 | p03661 | C++ | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/Tree_policy.hpp>
#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007
#define maxn 100005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2
using namespace __gnu_pbds;
using namespace std ;
typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
i64 a[2*maxn] ;
int main()
{
i64 i , j , k , l , m , n ;
scanf("%lld",&n) ;
for(i=1 ; i<=n ; i++) scanf("%lld",&a[i]) ;
for(i=1 ; i<=n ; i++) a[i] += a[i-1] ;
i64 ans = abs( 2*a[1] - a[n] ) ;
for(i=1 ; i<n ; i++) ans = min( ans , abs(2*a[i]-a[n]) ) ;
printf("%lld\n",ans) ;
return 0 ;
}
| a.cc:3:10: fatal error: ext/pb_ds/Tree_policy.hpp: No such file or directory
3 | #include <ext/pb_ds/Tree_policy.hpp>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
|
s176592181 | p03661 | C++ | #include <fstream>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <sstream>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <queue>
#include <random>
using namespace std;
//INT_MAX
//LONG_LONG_MAX
template <class T>
T mmax(T a,T b){
if(a>=b){
return a;
}
return b;
}
template <class T>
T mmin(T a,T b){
if(a<=b){
return a;
}
return b;
}
long long gcd(long long a, long long b){
if(a<b){
swap(a,b);
}
while(b){
long long r = a%b;
a=b;
b=r;
}
return a;
}
long long lcm(long long a, long long b){
return (a*b)/gcd(a,b);
}
int isPrim(int a){
if(a==1){
return 0;
}
for(int i=2;i<=(a+1)/2;i++){
if(a%i==0){
return 0;
}
}
return 1;
}
long long mod_pow(long long x, long long n, long long mod){
//xのn乗を計算するのにn乗を2進表記にして計算
//x^22 = x^16 + x^4 + x^2
long long ret=1;
while(n>0){
if(n&1){
ret=(ret*x)%mod;//答えに付加
}
x=(x*x)%mod;//2乗
n >>=1;
}
return ret;
}
struct XX{
int cnt;
int x;
int y;
};
class xxGreater {
public:
bool operator()(const XX& riLeft, const XX& riRight) const {
//第2条件
if((riLeft.x) == (riRight.x)){
return riLeft.y > riRight.y;//<:昇順(小さいものから順番)、>:降順(大きいものから順番)
}
//第1条件
return (riLeft.x) > (riRight.x);
}
};
////union-find
//int ppar[200000];
//int rrank[200000];
//
//void init(int n){
// for(int i=0;i<n;i++){
// ppar[i]=i;
// rrank[i]=0;
// }
//}
//
//int find(int x){
// if(ppar[x]==x){
// return x;
// }else{
// return ppar[x]=find(ppar[x]);
// }
//}
//
//void unite(int x,int y){
// x=find(x);
// y=find(y);
// if(x==y){
// return;
// }
// if(rrank[x]<rrank[y]){
// ppar[x]=y;
// }else{
// ppar[y]=x;
// if(rrank[x]==rrank[y]){
// rrank[x]++;
// }
// }
//}
//bool same(int x,int y){
// return find(x)==find(y);
//}
//
////kruskal
//struct edge{
// int u;
// int v;
// int cost;
//};
//
//bool comp(edge& e1,edge& e2){
// return e1.cost < e2.cost;
//}
//
//edge es[200000];
//
//long long kruskal(int V,int E){//V:頂点数,E:辺数
// sort(es,es+E,comp);
// init(V);
// long long res = 0;
// for(int i=0;i<E;i++){
// edge e = es[i];
// if(!same(e.u,e.v)){
// unite(e.u,e.v);
// res+=e.cost;
// }
// }
// return res;
//}
//dijkstra
//struct edge{
// long to;
// long cost;
//};
//typedef pair<long,long> P;//first:最短距離、second:頂点番号
//long V;
//vector<edge>G[1001];//G[各頂点番号]
//long d[1001];
//
//int dijkstra(long s){
// priority_queue<P,vector<P>> que;
// fill(d,d+V+1,-9223372036854775807);
// d[s]=0;
// que.push(P(0,s));
//
// int index=0;
// while(!que.empty()){
// P p=que.top();
// que.pop();
// long v=p.second;
// if(d[v]<p.first){
// continue;
// }
// for(int i=0;i<G[v].size();i++){
// edge e=G[v][i];
// if(d[e.to]<d[v]+e.cost){
// d[e.to]=d[v]+e.cost;
// que.push(P(d[e.to],e.to));
// }
// }
//
// if(index++>4000000){
// return -1;
// }
// }
// return 0;
//}
int main(int argc, const char * argv[])
{
//std::ios::sync_with_stdio(false);
//scanf("%s",S);
//scanf("%d",&N);
//sscanf(tmp.c_str(),"%dd%d%d",&time[i], &dice[i], &z[i]);
//getline(cin, target);
//cin >> x >> y;
//テスト用
//ifstream ifs( "1_06.txt" );
//ifs >> a;
//ここから
int n;
cin >> n;
long long a[100];
long long sum=0;
for(int i=0;i<n;i++){
cin >> a[i];
sum+=a[i];
}
long long tmp=0;
long long ans=INT_MAX;
for(int i=0;i<n-1;i++){
tmp+=a[i];
if(ans>abs(tmp-(sum-tmp))){
ans=abs(tmp-(sum-tmp));
}
}
cout << ans << endl;
//cout << ans << endl;
//ここまで
//cout << "ans" << endl;改行含む
//printf("%.0f\n",ans);//小数点以下表示なし
//printf("%.7f\n",p);
//printf("%f\n",pow(2,ans.size()));
return 0;
}
| a.cc: In function 'int main(int, const char**)':
a.cc:228:19: error: 'INT_MAX' was not declared in this scope
228 | long long ans=INT_MAX;
| ^~~~~~~
a.cc:15:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
14 | #include <random>
+++ |+#include <climits>
15 |
|
s108260831 | p03661 | C++ | #include<iostream>
using namespace std;
typedef long long ll;
ll abs(ll n){ return (n > 0 ? n : -n); }
int main(){
int n; cin >> n;
ll a[n];
ll sum = 0;
for(int i = 0; i < n; ++i){
cin >> a[i];
sum += a[i];
}
ll subs = 0;
ll ans = 1145141919810364364;
for(int i = 0; i < n - 1; ++i){
subs += a[i];
ans = min<ll>(ans, abs(subs - (sum - subs)));
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:19:39: error: call of overloaded 'abs(ll)' is ambiguous
19 | ans = min<ll>(ans, abs(subs - (sum - subs)));
| ~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
from /usr/include/c++/14/ext/string_conversions.h:43,
from /usr/include/c++/14/bits/basic_string.h:4154,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:5:4: note: candidate: 'll abs(ll)'
5 | ll abs(ll n){ return (n > 0 ? n : -n); }
| ^~~
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: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:79:3: note: candidate: 'constexpr long double std::abs(long double)'
79 | abs(long double __x)
| ^~~
/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:71:3: note: candidate: 'constexpr double std::abs(double)'
71 | abs(double __x)
| ^~~
/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:56:3: note: candidate: 'long int std::abs(long int)'
56 | abs(long __i) { return __builtin_labs(__i); }
| ^~~
|
s100193741 | p03661 | C++ | /*
* daruma_otoshi_2016D.cpp
* ICPC2016 Domestic D
*
* Created on: 2017/07/13
* Author: LitMc
*/
//#define MYDEBUG
#include <bits/stdc++.h>
#ifdef MYDEBUG
#define dbp(x) cout<<#x<<": "<<x<<endl
#define dbp2(x,y) cout<<#x<<","<<#y<<": "<<x<<","<<y<<endl
#define dbp3(x,y,z) cout<<#x<<","<<#y<<","<<#z<<": "<<x<<","<<y<<","<<z<<endl
#define dbp4(w,x,y,z) cout<<#w<<","<<#x<<","<<#y<<","<<#z<<": "<<w<<","<<x<<","<<y<<","<<z<<endl
#define ifcin(x) std::ifstream cin(x)
#else
#define dbp(x)
#define dbp2(x,y)
#define dbp3(x,y,z)
#define dbp4(w,x,y,z)
#define ifcin(x)
#endif
#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
#define rep(i, from, to) for(int i=from; i<to; ++i)
#define REP(i, from, to) for(int i=from; i<=to; ++i)
#define EPS = 1e-14;
using std::vector;
using std::cout;
using std::cin;
using std::endl;
using std::max;
using std::min;
using std::swap;
using std::string;
using std::fill;
using std::pair;
using std::sort;
using std::reverse;
using std::pair;
using std::greater;
using std::priority_queue;
using std::ostream;
template<typename T>
ostream& operator<<(ostream& out, const vector<vector<T> >& v) {
for (size_t i = 0; i < v.size(); ++i) {
out << v[i] << endl;
}
return out;
}
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
out << "[";
size_t last = v.size() - 1;
for (size_t i = 0; i < v.size(); ++i) {
out << v[i];
if (i != last) {
out << ",";
}
}
out << "]";
return out;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& p) {
out << "(" << p.first << ", " << p.second << ")";
return out;
}
typedef pair<int, int> P;
bool cmp(const P &p1, const P &p2) {
if (p1.first == p2.first) {
return p1.second > p2.second;
} else {
return p1.first < p2.first;
}
}
static const int MAX_N = 100010 * 2;
ll a[MAX_N];
ll sum[MAX_N];
int n;
void solve() {
cin >> n;
REP(i,1,n)
{
cin >> a[i];
sum[i] = a[i] + sum[i - 1];
}
//[1, k], [k+1, n]
ll mini = INT_MAX;
for (int k = 1; k + 1 <= n; ++k) {
ll snuke = sum[k] - sum[0];
ll arai = sum[n] - sum[k];
mini = min(abs(snuke - arai), mini);
}
cout << mini << endl;
}
int main() {
solve();
}
| a.cc: In function 'void solve()':
a.cc:100:15: error: no matching function for call to 'min(int, long long int&)'
100 | mini = min(abs(snuke - arai), mini);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:61,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:10:
/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:100:15: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
100 | mini = min(abs(snuke - arai), mini);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/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
In file included from /usr/include/c++/14/algorithm:60:
/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
/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:100:15: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
100 | mini = min(abs(snuke - arai), mini);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.