submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3
values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s357572384 | p03659 | C++ | #include<stdio.h>
#include <algorithm>
#include<iostream>
#include<string.h>
#include<vector>
#include<stdlib.h>
#include<math.h>
#include<queue>
#include<deque>
#include<ctype.h>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<algorithm>
#define INF 0x3f3f3f3f
#define FAST_IO ios::sync_with_stdio(false)
const double PI = acos(-1.0);
const double eps = 1e-6;
const int MAX=1e5+10;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
#define gcd(a,b) __gcd(a,b)
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll qpow(ll a,ll b){ll r=1,t=a; while(b){if(b&1)r=(r*t)%mod;b>>=1;t=(t*t)%mod;}return r;}
inline ll inv1(ll b){return qpow(b,mod-2);}
inline ll exgcd(ll a,ll b,ll &x,ll &y){if(!b){x=1;y=0;return a;}ll r=exgcd(b,a%b,y,x);y-=(a/b)*x;return r;}
inline ll read(){ll x=0,f=1;char c=getchar();for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;for(;isdigit(c);c=getchar()) x=x*10+c-'0';return x*f;}
//freopen( "in.txt" , "r" , stdin );
//freopen( "data.txt" , "w" , stdout );
ll a[MAX*2];
int main()
{
ll n,x,y;
ll sum=0;
scanf("%lld",&n);
for(int i=1;i<=n;i++)
{
scanf("%lld",&a[i]);
sum+=a[i];
}
x=a[1],y=sum-a[1];
int ans=abs(x-y);
for(int i=2;i<=n-1;i++)
{
y-=a[i];
x+=a[i];
ans=min(ans,abs(x-y));
}
printf("%lld\n",ans);
return 0;
}
| a.cc: In function 'int main()':
a.cc:51:16: error: no matching function for call to 'min(int&, long long int)'
51 | ans=min(ans,abs(x-y));
| ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:51:16: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
51 | ans=min(ans,abs(x-y));
| ~~~^~~~~~~~~~~~~~
/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:51:16: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
51 | ans=min(ans,abs(x-y));
| ~~~^~~~~~~~~~~~~~
|
s265314549 | p03659 | Java | import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Main main = new Main();
main.run();
}
void run() {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
long[] A=new int[N];
long sum=0;
for (int i = 0; i < N; i++) {
long buf=sc.nextLong();
A[i]=buf;
sum+=buf;
}
long sunuke=0;
long arai=0;
long min=Long.MAX_VALUE;
for (int i = 0; i < N; i++) {
sunuke+=A[i];
if(i+1<N) {
arai=sum-sunuke;
long diff=Math.abs(sunuke-arai);
min=Math.min(min,diff);
}
}
System.out.println(min);
}
//以下テンプレート
public static int[] extgcd(int a, int b) {
int x0 = 1;
int x1 = 0;
int y0 = 0;
int y1 = 1;
while (b != 0) {
int q = a / b;
int r = a % b;
int x2 = x0 - q * x1;
int y2 = y0 - q * y1;
a = b;
b = r;
x0 = x1;
x1 = x2;
y0 = y1;
y1 = y2;
}
return new int[] { a, x0, y0 };
}
static int gcd(int a, int b) {
if (b == 0)
return a;
if (a < b) {
int t = a;
a = b;
b = t;
}
return gcd(b, a % b);
}
static int lcm(int a, int b) {
return a * b / gcd(a, b);
}
static void swap(int[] a) {
int t;
t = a[0];
a[0] = a[1];
a[1] = t;
return;
}
static <T> void output(List<T> list) {
for (int i = 0; i < list.size(); i++) {
System.out.print(list.get(i));
if (i != list.size() - 1) {
System.out.print(" ");
} else {
nl();
}
}
}
static void output(String[][] str) {
for (int i = 0; i < str.length; i++) {
for (int j = 0; j < str[i].length; j++) {
print(str[i][j]);
}
nl();
}
}
static void output(boolean flg, String Yes, String No) {
if (flg) {
pln(Yes);
} else {
pln(No);
}
}
static void output(String[][] str, int digit) {
String dig = "%" + String.valueOf(digit) + "s";
for (int i = 0; i < str.length; i++) {
for (int j = 0; j < str[i].length; j++) {
System.out.printf(dig, str[i][j]);
}
nl();
}
}
static void pln(String str) {
System.out.println(str);
}
static void pln(int x) {
System.out.println(x);
}
static void print(String str) {
System.out.print(str);
}
static void print(int x) {
System.out.print(x);
}
static void print(String str, int times) {
for (int i = 0; i < times; i++) {
print(str);
}
}
static void print(int x, int times) {
for (int i = 0; i < times; i++) {
print(x);
}
}
static void nl() {
System.out.println();
}
}
| Main.java:16: error: incompatible types: int[] cannot be converted to long[]
long[] A=new int[N];
^
1 error
|
s381502161 | p03659 | 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[] sum = new long[N + 1];
long ans = 1000000000L;
for (int i = 0; i < N; i++){
a[i] = scanner.nextLong();
}
sum[0] = a[0];
for (int i = 1; i < N; i++){
sum[i] = sum[i - 1] + a[i];
}
for (int i = 0; i < N - 1; i++){
ans = Math.min(ans, Math.abs(sum[N - 1] - 2 * sum[i]));
}
System.out.println(ans);
}
}
| Main.java:11: error: incompatible types: possible lossy conversion from long to int
a[i] = scanner.nextLong();
^
1 error
|
s027980660 | p03659 | C++ | #include<bits/stdc++.h>
using namespace std;
#define inf 1<<60
int main(){
int n;cin>>n;
vector<int>a(n);
vector<int>b(n);
for(int i=0;i<n;++i){
cin>>a[i];
b[0]=a[0];
if(i!=0)b[i]=b[i-1]+a[i];
}
cout<<endl;
long long int ans=inf;
for(int i=0;i<n-1;i++){
int s_ans=abs(b[i]-(b[n-1]-b[i]));
ans=min(ans,s_ans);
}
cout<<ans<<endl;
}
| a.cc: In function 'int main()':
a.cc:3:14: warning: left shift count >= width of type [-Wshift-count-overflow]
3 | #define inf 1<<60
| ~^~~~
a.cc:14:27: note: in expansion of macro 'inf'
14 | long long int ans=inf;
| ^~~
a.cc:17:24: error: no matching function for call to 'min(long long int&, int&)'
17 | ans=min(ans,s_ans);
| ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:17:24: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
17 | ans=min(ans,s_ans);
| ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:17:24: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
17 | ans=min(ans,s_ans);
| ~~~^~~~~~~~~~~
|
s231243803 | p03659 | Java | import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Scanner;
public class Main{
static final Scanner sc=new Scanner(System.in);
public static void main(String[]args){
int N=sc.nextInt();
long[]a=new long[N];
for(int i=0;i<N;i++){
a[i]=sc.nextLong();
}
long[]s=new long[N];
s[0]=a[0];
for(int i=1;i<N;i++){
s[i]=s[i-1]+a[i];
}
long min=100000000000;
long r=0;
for(int i=0;i<N;i++){
r=s[N-1]-s[i];
if(Math.abs(r-s[i])<min){
min=Math.abs(r-s[i]);
}
}
if(N==2){
min=Math.abs(a[0]-a[1]);
}
System.out.println(min);
}
}
| Main.java:19: error: integer number too large
long min=100000000000;
^
1 error
|
s333622377 | p03659 | C++ | #include <iostream>
#include <algorithm>
using namespace std;
typedef ll;
int main() {
int N;
cin >> N;
ll asum[210000] = { };
for(int i = 0; i < N; i++) {
ll a;
cin >> a;
asum[i + 1] = asum[i] + a;
}
ll mi = 1100000000;
for(int i = 1; i <= N - 1; i++) {
mi = min(mi, abs(asum[i] - (asum[N] - asum[i])));
}
cout << mi << endl;
return 0;
}
| a.cc:5:9: error: 'll' does not name a type
5 | typedef ll;
| ^~
a.cc: In function 'int main()':
a.cc:10:9: error: 'll' was not declared in this scope
10 | ll asum[210000] = { };
| ^~
a.cc:13:19: error: expected ';' before 'a'
13 | ll a;
| ^~
| ;
a.cc:14:24: error: 'a' was not declared in this scope
14 | cin >> a;
| ^
a.cc:15:17: error: 'asum' was not declared in this scope
15 | asum[i + 1] = asum[i] + a;
| ^~~~
a.cc:18:11: error: expected ';' before 'mi'
18 | ll mi = 1100000000;
| ^~~
| ;
a.cc:20:17: error: 'mi' was not declared in this scope; did you mean 'i'?
20 | mi = min(mi, abs(asum[i] - (asum[N] - asum[i])));
| ^~
| i
a.cc:20:34: error: 'asum' was not declared in this scope
20 | mi = min(mi, abs(asum[i] - (asum[N] - asum[i])));
| ^~~~
a.cc:22:17: error: 'mi' was not declared in this scope
22 | cout << mi << endl;
| ^~
|
s136328556 | p03659 | C++ | #include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
int a[100010];
int main() {
int N;
cin >> N;
rep(i, N)cin >> a[i];
long long sum = accumulate(a, a + N, 0);
long long sun = 0;
long long mi = long long (2e18);
rep(i, N-1) {
sun += a[i];
mi = min(mi, abs(sun - (sum - sun)));
}
cout << mi << endl;
} | a.cc: In function 'int main()':
a.cc:20:20: error: expected primary-expression before 'long'
20 | long long mi = long long (2e18);
| ^~~~
|
s883822152 | p03659 | C++ | int N;
int main (){
cin >> N;
int a[N];
long long int sum = 0;
for(int i=0; i<N; i++){
cin >> a[i];
sum += a[i];
}
long long int dif = 0;
long long int ans = 1000000001;
if ( N == 2) {
cout << abs(a[1] - a[0]) << endl;
return 0;
}
for(int i=0; i<N-1; i++){
dif += sum - a[i];
ans = min(abs(sum - dif), ans );
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:3:5: error: 'cin' was not declared in this scope
3 | cin >> N;
| ^~~
a.cc:13:9: error: 'cout' was not declared in this scope
13 | cout << abs(a[1] - a[0]) << endl;
| ^~~~
a.cc:13:17: error: 'abs' was not declared in this scope; did you mean 'ans'?
13 | cout << abs(a[1] - a[0]) << endl;
| ^~~
| ans
a.cc:13:37: error: 'endl' was not declared in this scope
13 | cout << abs(a[1] - a[0]) << endl;
| ^~~~
a.cc:18:19: error: 'abs' was not declared in this scope; did you mean 'ans'?
18 | ans = min(abs(sum - dif), ans );
| ^~~
| ans
a.cc:18:15: error: 'min' was not declared in this scope; did you mean 'main'?
18 | ans = min(abs(sum - dif), ans );
| ^~~
| main
a.cc:20:5: error: 'cout' was not declared in this scope
20 | cout << ans << endl;
| ^~~~
a.cc:20:20: error: 'endl' was not declared in this scope
20 | cout << ans << endl;
| ^~~~
|
s707346127 | p03659 | C++ | #include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const int INF = 1000000000;
using ll = long long int;
using vi = vector<int>;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
//template <class T>T max(T x,T y){if(x>y){return x;}else{return y;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return 1; } return 0; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return 1; } return 0; }
///////////////////////////////////////////
ll num[200001];
int dp[200001];
ll pls;
//int rec(int x){
// // cout<<x<<endl;
// if(x<0)return pls;
// if(dp[x]>=0)return dp[x];
// dp[x] = min(abs(rec(x-1)),abs(rec(x-1)-2*num[x]));
// return dp[x];
//}
int main(){
memset(dp,-1, sizeof(dp));
ll n;
cin>>n;
pls=0;
cin>>num[0];
pls=num[0];
for(int i=1;i<n;i++){cin>>num[i];pls+=num[i];num[i]+=num[i-1];}
ll ans=#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const int INF = 1000000000;
using ll = long long int;
using vi = vector<int>;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
//template <class T>T max(T x,T y){if(x>y){return x;}else{return y;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return 1; } return 0; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return 1; } return 0; }
///////////////////////////////////////////
ll num[200001];
int dp[200001];
ll pls;
//int rec(int x){
// // cout<<x<<endl;
// if(x<0)return pls;
// if(dp[x]>=0)return dp[x];
// dp[x] = min(abs(rec(x-1)),abs(rec(x-1)-2*num[x]));
// return dp[x];
//}
int main(){
memset(dp,-1, sizeof(dp));
ll n;
cin>>n;
pls=0;
cin>>num[0];
pls=num[0];
for(int i=1;i<n;i++){cin>>num[i];pls+=num[i];num[i]+=num[i-1];}
ll ans=1000000000000000000LL;
for (int i = 0; i < n-1; i++) {
chmin(ans,abs(pls - 2*num[i]));
}
cout<<ans<<endl;
return 0;
};
for (int i = 0; i < n-1; i++) {
chmin(ans,abs(pls - 2*num[i]));
}
cout<<ans<<endl;
return 0;
} | a.cc:36:12: error: stray '#' in program
36 | ll ans=#include <bits/stdc++.h>
| ^
a.cc: In function 'int main()':
a.cc:36:13: error: 'include' was not declared in this scope
36 | ll ans=#include <bits/stdc++.h>
| ^~~~~~~
a.cc:36:22: error: 'bits' was not declared in this scope
36 | ll ans=#include <bits/stdc++.h>
| ^~~~
a.cc:36:27: error: 'stdc' was not declared in this scope; did you mean 'std'?
36 | ll ans=#include <bits/stdc++.h>
| ^~~~
| std
a.cc:37:5: error: expected primary-expression before 'using'
37 | using namespace std;
| ^~~~~
a.cc:47:5: error: a template declaration cannot appear at block scope
47 | template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return 1; } return 0; }
| ^~~~~~~~
a.cc:63:13: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
63 | int main(){
| ^~
a.cc:63:13: note: remove parentheses to default-initialize a variable
63 | int main(){
| ^~
| --
a.cc:63:13: note: or replace parentheses with braces to value-initialize a variable
a.cc:63:15: error: a function-definition is not allowed here before '{' token
63 | int main(){
| ^
|
s747929153 | p03659 | C++ | #include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const int INF = 1000000000;
using ll = long long int;
using vi = vector<int>;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
//template <class T>T max(T x,T y){if(x>y){return x;}else{return y;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return 1; } return 0; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return 1; } return 0; }
///////////////////////////////////////////
ll num[200001];
int dp[200001];
ll pls;
//int rec(int x){
// // cout<<x<<endl;
// if(x<0)return pls;
// if(dp[x]>=0)return dp[x];
// dp[x] = min(abs(rec(x-1)),abs(rec(x-1)-2*num[x]));
// return dp[x];
//}
int main(){
memset(dp,-1, sizeof(dp));
ll n;
cin>>n;
pls=0;
cin>>num[0];
pls=num[0];
for(int i=1;i<n;i++){cin>>num[i];pls+=num[i];num[i]+=num[i-1];}
ll ans=#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const int INF = 1000000000;
using ll = long long int;
using vi = vector<int>;
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
//template <class T>T max(T x,T y){if(x>y){return x;}else{return y;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return 1; } return 0; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return 1; } return 0; }
///////////////////////////////////////////
ll num[200001];
int dp[200001];
ll pls;
//int rec(int x){
// // cout<<x<<endl;
// if(x<0)return pls;
// if(dp[x]>=0)return dp[x];
// dp[x] = min(abs(rec(x-1)),abs(rec(x-1)-2*num[x]));
// return dp[x];
//}
int main(){
memset(dp,-1, sizeof(dp));
ll n;
cin>>n;
pls=0;
cin>>num[0];
pls=num[0];
for(int i=1;i<n;i++){cin>>num[i];pls+=num[i];num[i]+=num[i-1];}
ll ans=1000000000000000000LL;
for (int i = 0; i < n-1; i++) {
chmin(ans,abs(pls - 2*num[i]));
}
cout<<ans<<endl;
return 0;
};
for (int i = 0; i < n-1; i++) {
chmin(ans,abs(pls - 2*num[i]));
}
cout<<ans<<endl;
return 0;
} | a.cc:36:12: error: stray '#' in program
36 | ll ans=#include <bits/stdc++.h>
| ^
a.cc: In function 'int main()':
a.cc:36:13: error: 'include' was not declared in this scope
36 | ll ans=#include <bits/stdc++.h>
| ^~~~~~~
a.cc:36:22: error: 'bits' was not declared in this scope
36 | ll ans=#include <bits/stdc++.h>
| ^~~~
a.cc:36:27: error: 'stdc' was not declared in this scope; did you mean 'std'?
36 | ll ans=#include <bits/stdc++.h>
| ^~~~
| std
a.cc:37:5: error: expected primary-expression before 'using'
37 | using namespace std;
| ^~~~~
a.cc:47:5: error: a template declaration cannot appear at block scope
47 | template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return 1; } return 0; }
| ^~~~~~~~
a.cc:63:13: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
63 | int main(){
| ^~
a.cc:63:13: note: remove parentheses to default-initialize a variable
63 | int main(){
| ^~
| --
a.cc:63:13: note: or replace parentheses with braces to value-initialize a variable
a.cc:63:15: error: a function-definition is not allowed here before '{' token
63 | int main(){
| ^
|
s639169630 | p03659 | C | #include<bits/stdc++.h>
using namespace std;
template <class T> T min2(T a,T b){if(a<b) return a;return b;};
typedef long long ll;
ll a[200005];
int main()
{
int n;
cin>>n>>a[0];
for(int i=1;i<n;i++)
{
scanf(" %lld",a+i);
a[i]+=a[i-1];
}
ll ans=abs(2*a[0]-a[n-1]);
for(int i=1;i<n-1;i++)
{
ans=min(ans,abs(2*a[i]-a[n-1]));
}
cout<<ans<<endl;
return 0;
} | main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
1 | #include<bits/stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s888936434 | p03659 | C++ | #include<iostream>
#include<vector>
#include<algorithm>
#include <functional>
#include <cstdlib>
#include <cmath>
using namespace std;
int main()
{
int n, input, res = INT_MAX, x = 0, y = 0, i, j, k;
vector<int> a;
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> input;
a.push_back(input);
}
sort(a.begin(), a.end());
for (i = 1; i < n; i++)
{
x = y = 0;
for (j = 0; j < i; j++)
{
x += a[j];
}
for (k = j; k < n; k++)
{
y += a[k];
}
if (res > abs(x - y))
{
res = abs(x - y);
}
cout << res << endl;
}
cout << res << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:12:29: error: 'INT_MAX' was not declared in this scope
12 | int n, input, res = INT_MAX, x = 0, y = 0, i, j, k;
| ^~~~~~~
a.cc:7:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
6 | #include <cmath>
+++ |+#include <climits>
7 |
a.cc:24:14: error: 'i' was not declared in this scope
24 | for (i = 1; i < n; i++)
| ^
a.cc:26:17: error: 'x' was not declared in this scope
26 | x = y = 0;
| ^
a.cc:26:21: error: 'y' was not declared in this scope
26 | x = y = 0;
| ^
a.cc:27:22: error: 'j' was not declared in this scope
27 | for (j = 0; j < i; j++)
| ^
a.cc:31:22: error: 'k' was not declared in this scope
31 | for (k = j; k < n; k++)
| ^
a.cc:31:26: error: 'j' was not declared in this scope
31 | for (k = j; k < n; k++)
| ^
|
s072883224 | p03659 | C++ | #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
typedef long long int lli;
const lli int MAX = 2e5;
const lli int AMAX = 1e9;
int N;
lli a[MAX];
lli sum = 0;
int main() {
cin >> N;
rep(i, N) {
cin >> a[i];
sum += a[i];
}
lli snk = 0;
lli ans = AMAX * MAX;
for (int i = 0;i <= N - 2;i++) {
snk += a[i];
lli now = abs(sum - 2 * snk);
if (now<ans) ans = now;
}
cout << ans;
} | a.cc:11:1: error: two or more data types in declaration of 'MAX'
11 | const lli int MAX = 2e5;
| ^~~~~
a.cc:12:1: error: two or more data types in declaration of 'AMAX'
12 | const lli int AMAX = 1e9;
| ^~~~~
a.cc:14:7: error: 'MAX' was not declared in this scope
14 | lli a[MAX];
| ^~~
a.cc: In function 'int main()':
a.cc:20:24: error: 'a' was not declared in this scope
20 | cin >> a[i];
| ^
a.cc:24:19: error: 'AMAX' was not declared in this scope
24 | lli ans = AMAX * MAX;
| ^~~~
a.cc:24:26: error: 'MAX' was not declared in this scope
24 | lli ans = AMAX * MAX;
| ^~~
a.cc:26:32: error: 'a' was not declared in this scope
26 | snk += a[i];
| ^
|
s818667990 | p03659 | C++ | #include<bits\stdc++.h>
using namespace std;
int diff(int x,int y)
{
if(x>y)
return x-y;
else
return y-x;
}
int main()
{
int a[1000],x,y,i,j,n,d[1000];
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
sort(a,a+n);
for(j=1;j<n;j++)
{
x=0;
y=0;
for(i=n-1;i>=j;i--)
{
y=y+a[i];
}
for(i=0;i<j;i++)
{
x=x+a[i];
}
d[j-1]=diff(x,y);
}
sort(d,d+(n-1));
printf("%d",d[0]);
}
| a.cc:1:9: fatal error: bits\stdc++.h: No such file or directory
1 | #include<bits\stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s214721556 | p03659 | C | #include<stdio.h>
#include<math.h>
int main()
{
int n,b=0,c=0,a[200000]={0};
scanf("%d",&n)==1
long long int min=20000000000;
for(int i=0;i<n;i++)
scanf("%d",&a[i]);
for(int j=0;j<n-1;j++){
for(int m=0;m<=j;m++)
b+=a[m];
for(int t=j+1;t<n;t++)
c+=a[t];
if(min>fabs(b-c)) min=fabs(b-c);
}
printf("%d\n",min);
return 0;
} | main.c: In function 'main':
main.c:6:26: error: expected ';' before 'long'
6 | scanf("%d",&n)==1
| ^
| ;
7 | long long int min=20000000000;
| ~~~~
main.c:16:12: error: 'min' undeclared (first use in this function); did you mean 'main'?
16 | if(min>fabs(b-c)) min=fabs(b-c);
| ^~~
| main
main.c:16:12: note: each undeclared identifier is reported only once for each function it appears in
|
s347043508 | p03659 | C | #include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
const int MAXN=2e5+5;
const int MOD=1000000000;
const LL INF=(2e5)*(1e9)+5;
LL a[MAXN];
LL sum[MAXN];
int main()
{
ios::sync_with_stdio(false);
int n;
while(cin>>n)
{
LL tot=0;
for(int i=1;i<=n;i++)
{
cin>>a[i];
sum[i]=sum[i-1]+a[i];
tot+=a[i];
}
LL Min=INF;
for(int i=1;i<n;i++)
{
if(Min>abs(2*sum[i]-tot))
Min=abs(2*sum[i]-tot);
}
cout<<Min<<endl;
}
return 0;
} | main.c:1:9: fatal error: iostream: No such file or directory
1 | #include<iostream>
| ^~~~~~~~~~
compilation terminated.
|
s595171754 | p03659 | C++ | #include
<algorithm>
#include
<iostream>
#include
<vector>
using
namespace
std;
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:1:9: error: #include expects "FILENAME" or <FILENAME>
1 | #include
| ^
a.cc:3:9: error: #include expects "FILENAME" or <FILENAME>
3 | #include
| ^
a.cc:5:9: error: #include expects "FILENAME" or <FILENAME>
5 | #include
| ^
a.cc:2:1: error: expected unqualified-id before '<' token
2 | <algorithm>
| ^
a.cc: In function 'int main()':
a.cc:27:1: error: 'cin' was not declared in this scope
27 | cin
| ^~~
a.cc:30:1: error: 'vector' was not declared in this scope
30 | vector
| ^~~~~~
a.cc:32:1: error: expected primary-expression before 'long'
32 | long
| ^~~~
a.cc:49:1: error: 'a' was not declared in this scope
49 | a[i];
| ^
a.cc:67:1: error: 'a' was not declared in this scope
67 | a[i];
| ^
a.cc:75:9: error: 'abs' was not declared in this scope; did you mean 'ans'?
75 | min(ans,abs(X
| ^~~
| ans
a.cc:75:1: error: 'min' was not declared in this scope; did you mean 'main'?
75 | min(ans,abs(X
| ^~~
| main
a.cc:81:1: error: 'cout' was not declared in this scope
81 | cout
| ^~~~
a.cc:85:1: error: 'endl' was not declared in this scope
85 | endl;
| ^~~~
|
s744811196 | p03659 | C++ | #include <bits/stdc++.h>
#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
typedef long long ll;
using namespace std;
const int INF = 2e9,MOD = 1e9 + 7;
const ll LINF = 1e18;
//while(x!=0){
//sum+=x%10;
// x/=10;
//}
//各桁の和
//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力
//s.find(w[i])==string::npos
//findの使い方
//for(int i=0;i<n;i++){
// b[i]=x%2;
//x/=2;
//}二進数
long long int n=1,cnt=0,ans=INF,a[1000000000],b,c,cmp[1000000000],data,m,h,w,x,y,xcmp=0,ycmp=0,sum=0;
string s;
vector<int> z;
int main(void){
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n;
rep(i,n){
cin >> a[i];
}
cmp[0]=a[0];
cnt=n-1;
rep(i,n-1){
cmp[i+1]=cmp[i]+a[i+1];
}
rep(i,n-1){
ans=min(Abs(cmp[i],cmp[cnt]-cmp[i]),ans);
}
Cout(ans);
return 0;
}
| /tmp/ccMuCpfk.o: in function `main':
a.cc:(.text+0x90): relocation truncated to fit: R_X86_64_PC32 against symbol `cmp' defined in .bss section in /tmp/ccMuCpfk.o
a.cc:(.text+0xbf): relocation truncated to fit: R_X86_64_PC32 against symbol `cmp' defined in .bss section in /tmp/ccMuCpfk.o
a.cc:(.text+0xf9): relocation truncated to fit: R_X86_64_PC32 against symbol `cmp' defined in .bss section in /tmp/ccMuCpfk.o
a.cc:(.text+0x137): relocation truncated to fit: R_X86_64_PC32 against symbol `cmp' defined in .bss section in /tmp/ccMuCpfk.o
a.cc:(.text+0x14e): relocation truncated to fit: R_X86_64_PC32 against symbol `cmp' defined in .bss section in /tmp/ccMuCpfk.o
a.cc:(.text+0x16c): relocation truncated to fit: R_X86_64_PC32 against symbol `cmp' defined in .bss section in /tmp/ccMuCpfk.o
a.cc:(.text+0x197): relocation truncated to fit: R_X86_64_PC32 against symbol `cmp' defined in .bss section in /tmp/ccMuCpfk.o
a.cc:(.text+0x1ae): relocation truncated to fit: R_X86_64_PC32 against symbol `cmp' defined in .bss section in /tmp/ccMuCpfk.o
a.cc:(.text+0x1cc): relocation truncated to fit: R_X86_64_PC32 against symbol `cmp' defined in .bss section in /tmp/ccMuCpfk.o
/tmp/ccMuCpfk.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x267): relocation truncated to fit: R_X86_64_PC32 against symbol `s[abi:cxx11]' defined in .bss section in /tmp/ccMuCpfk.o
a.cc:(.text+0x280): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s431798701 | p03659 | C++ | #include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ll n;
cin >> n;
ll sum[n + 1] = {};
for(ll i = 0; i < n; i++){
ll a;
cin >> a;
sum[i + 1] = sum[i] + a;
}
ll ans = 1145148931919810;
for(ll i = 1; i < n; i++) ans = min(ans, (ll)abs(sum[i] - (sum[n] - sum[i])));
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:14:52: error: 'su\U0000ff4d' was not declared in this scope
14 | for(ll i = 1; i < n; i++) ans = min(ans, (ll)abs(sum[i] - (sum[n] - sum[i])));
| ^~~~
|
s291860827 | p03659 | C++ | #include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
ll n;
cin >> n;
ll sum[n + 1] = {};
for(ll i = 0; i < n; i++){
ll a;
cin >> a;
sum[i + 1] = sum[i] + a;
}
ll ans = 1145148931919810;
for(ll i = 1; i < n; i++) ans = min(ans, (ll)abs(suu[i] - (sum[n] - sum[i])));
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:14:52: error: 'suu' was not declared in this scope; did you mean 'sum'?
14 | for(ll i = 1; i < n; i++) ans = min(ans, (ll)abs(suu[i] - (sum[n] - sum[i])));
| ^~~
| sum
|
s973029447 | p03659 | C++ | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
int main() {
int N;
cin >> N;
vector<long long> a(n);
long long int sum = 0;
for (int i = 0; i < N; ++i) {
cin >> a[i];
sum += a[i];
}
long long int ans = 1000000000000000000LL;
long long int x = 0;
for (int i = 0; i < N; i++) {
x += a[i];
if (i + 1 < N) {
ans = min(ans, abs(sum - 2 * x));
}
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:11:3: error: 'vector' was not declared in this scope
11 | vector<long long> a(n);
| ^~~~~~
a.cc:5:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
4 | #include <iostream>
+++ |+#include <vector>
5 |
a.cc:11:10: error: expected primary-expression before 'long'
11 | vector<long long> a(n);
| ^~~~
a.cc:14:12: error: 'a' was not declared in this scope
14 | cin >> a[i];
| ^
a.cc:21:10: error: 'a' was not declared in this scope
21 | x += a[i];
| ^
|
s997979247 | p03659 | C++ | #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define cost first
#define from second.first
#define to second.second
#define MOD (1000000007ll)
#define l_ength size
ll p[123456],q[123456];
void mul_mod(ll& a, ll b){
a *= b;
a %= MOD;
}
void add_mod(ll& a, ll b){
b += MOD;
a += b;
a %= MOD;
}
ll inv(ll x){
ll a = MOD-2,ans=1ll;
while(a > 0){
if((a&1)>0){
mul_mod(ans,x);
}
a /= 2;
mul_mod(x,x);
}
return ans;
}
ll comb(int x, int y){
ll ans=1ll;
if(x <= 0 || y < 0 || (x-y) < 0){
return 0ll;
}
mul_mod(ans,p[x]);
mul_mod(ans,q[y]);
mul_mod(ans,q[x-y]);
return ans;
}
int main(void){
int n,i;
ll a[225816],ans=INFLL;
a[0] = 0ll;
cin >> n;
for(i=1; i<=n; ++i){
cin >> a[i];
a[i] += a[i-1];
}
for(i=1; i<n; ++i){
ans = min(ans,abs(a[i]*2-a[n]));
}
cout << ans << endl;
return 0;
}#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define cost first
#define from second.first
#define to second.second
#define MOD (1000000007ll)
#define l_ength size
ll p[123456],q[123456];
void mul_mod(ll& a, ll b){
a *= b;
a %= MOD;
}
void add_mod(ll& a, ll b){
b += MOD;
a += b;
a %= MOD;
}
ll inv(ll x){
ll a = MOD-2,ans=1ll;
while(a > 0){
if((a&1)>0){
mul_mod(ans,x);
}
a /= 2;
mul_mod(x,x);
}
return ans;
}
ll comb(int x, int y){
ll ans=1ll;
if(x <= 0 || y < 0 || (x-y) < 0){
return 0ll;
}
mul_mod(ans,p[x]);
mul_mod(ans,q[y]);
mul_mod(ans,q[x-y]);
return ans;
}
int main(void){
int n,i;
ll a[225816],ans=INFLL;
a[0] = 0ll;
cin >> n;
for(i=1; i<=n; ++i){
cin >> a[i];
a[i] += a[i-1];
}
for(i=1; i<n; ++i){
ans = min(ans,abs(a[i]*2-a[n]));
}
cout << ans << endl;
return 0;
} | a.cc:65:2: error: stray '#' in program
65 | }#include "bits/stdc++.h"
| ^
a.cc:65:3: error: 'include' does not name a type
65 | }#include "bits/stdc++.h"
| ^~~~~~~
a.cc:78:4: error: redefinition of 'll p [123456]'
78 | ll p[123456],q[123456];
| ^
a.cc:14:4: note: 'll p [123456]' previously declared here
14 | ll p[123456],q[123456];
| ^
a.cc:78:14: error: redefinition of 'll q [123456]'
78 | ll p[123456],q[123456];
| ^
a.cc:14:14: note: 'll q [123456]' previously declared here
14 | ll p[123456],q[123456];
| ^
a.cc:80:6: error: redefinition of 'void mul_mod(ll&, ll)'
80 | void mul_mod(ll& a, ll b){
| ^~~~~~~
a.cc:16:6: note: 'void mul_mod(ll&, ll)' previously defined here
16 | void mul_mod(ll& a, ll b){
| ^~~~~~~
a.cc:85:6: error: redefinition of 'void add_mod(ll&, ll)'
85 | void add_mod(ll& a, ll b){
| ^~~~~~~
a.cc:21:6: note: 'void add_mod(ll&, ll)' previously defined here
21 | void add_mod(ll& a, ll b){
| ^~~~~~~
a.cc:91:4: error: redefinition of 'll inv(ll)'
91 | ll inv(ll x){
| ^~~
a.cc:27:4: note: 'll inv(ll)' previously defined here
27 | ll inv(ll x){
| ^~~
a.cc:103:4: error: redefinition of 'll comb(int, int)'
103 | ll comb(int x, int y){
| ^~~~
a.cc:39:4: note: 'll comb(int, int)' previously defined here
39 | ll comb(int x, int y){
| ^~~~
a.cc:115:5: error: redefinition of 'int main()'
115 | int main(void){
| ^~~~
a.cc:51:5: note: 'int main()' previously defined here
51 | int main(void){
| ^~~~
|
s969005850 | p03659 | C++ | #include<cstdio>
#include<iomanip>
#include<cmath>
#include<cstdlib>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<iostream>
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define rep(i,n) for(int i=1;i<=n;i++)
#define c(ans) cout<<ans<<endl;
using namespace std;
typedef long long ll;
const int MAXN=2e5+10;
ll a[MAXN];
int main(){
IO;
ll n, t;
a[0] = 0;
cin >> n;
for(ll i = 1; i <= n; i++){
cin >> t;
a[i] = a[i-1] + t;
}
ll ans = 1 << 29;
rep(ll i = 1; i < n; i++){
ans = min(ans, abs(a[n] - a[i]*2));
}
cout << ans << endl;
return 0;
} | a.cc:26:33: error: macro "rep" requires 2 arguments, but only 1 given
26 | rep(ll i = 1; i < n; i++){
| ^
a.cc:10:9: note: macro "rep" defined here
10 | #define rep(i,n) for(int i=1;i<=n;i++)
| ^~~
a.cc: In function 'int main()':
a.cc:26:9: error: 'rep' was not declared in this scope
26 | rep(ll i = 1; i < n; i++){
| ^~~
|
s170221790 | p03659 | C | #include <iostream>
#include<cmath>
using namespace std;
int main()
{
int n,i,j;
int min1=100,min2;
int s1=0,s2=0,s=0;
cin>>n;
long long a[n];
for(i=0;i<n;i++){
cin>>a[i];
}
for(i=0;i<n;i++){
s+=a[i];
}
for(i=0;i<n-1;i++){
for(j=0;j<=i;j++){
s1+=a[j];
}
s2=s-s1;
min2=abs(s1-s2);
if(min2<min1) min1=min2;
}
cout<<min1<<endl;
return 0;
}
| main.c:1:10: fatal error: iostream: No such file or directory
1 | #include <iostream>
| ^~~~~~~~~~
compilation terminated.
|
s663215220 | p03659 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int n;
cin >> n;
long long sum = 0;
vector<long long> a(n);
for(int i = 0; i < n; i++)
{
cin >> a[i];
sum += a[i];
}
long long tmp = 0;
long long ans = 2*max_element(a.begin(), a.end());
for(int i = 0; i < n - 1; i++)
{
tmp += a[i];
long long ttmp = sum - 2*tmp > 0 ? sum - 2*tmp : 2*tmp - sum;
if(ans > ttmp)
{
ans = ttmp;
}
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:21:26: error: no match for 'operator*' (operand types are 'int' and '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >')
21 | long long ans = 2*max_element(a.begin(), a.end());
| ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| | |
| int __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >
|
s700776474 | p03659 | C++ | #include <algorithm>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;
using std::min;
using std::max;
using std::sort;
using std::abs;
typedef unsigned long long ll;
int main(void) {
ll n;
cin >> n;
vector<ll> a(n);
for (ll i = 0; i < n; i++) {
cin >> a[i];
}
ll all = 0;
for (ll i = 0; i < n; i++) {
all += a[i];
}
ll sum = a[0];
ll ans = abs(sum - (all - sum));
for (ll i = 1; i < n - 1; i++) {
sum += a[i];
ans = min(ans, abs(sum - (all - sum)));
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:43:17: error: call of overloaded 'abs(ll)' is ambiguous
43 | ll ans = abs(sum - (all - sum));
| ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79,
from /usr/include/c++/14/bits/stl_algo.h:71,
from /usr/include/c++/14/algorithm:61,
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); }
| ^~~
a.cc:46:27: error: call of overloaded 'abs(ll)' is ambiguous
46 | ans = min(ans, abs(sum - (all - sum)));
| ~~~^~~~~~~~~~~~~~~~~~~
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
/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); }
| ^~~
|
s110193320 | p03659 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
int main(){
int n;
cin >> n;
ll a[n], ansy=0;
for(int i=0;i<n;i++){
cin >> a[i];
ansy+=a[i];
}
ll ansx=a[i], ans = abs(ansy-ansx);
for(int i=1;i<n;i++){
ansx += a[i];
ansy -= a[i];
ans = min(ans, abs(ansx-ansy));
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:14:13: error: 'i' was not declared in this scope
14 | ll ansx=a[i], ans = abs(ansy-ansx);
| ^
a.cc:18:5: error: 'ans' was not declared in this scope; did you mean 'ansx'?
18 | ans = min(ans, abs(ansx-ansy));
| ^~~
| ansx
a.cc:20:11: error: 'ans' was not declared in this scope; did you mean 'ansx'?
20 | cout << ans << endl;
| ^~~
| ansx
|
s968625473 | p03659 | C++ | #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x) cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;
LL minabs=LONG_LONG_MAX;
LL sum=0;
LL N;
vector<LL> A;
LL a;
int main(){
cin>>N;
REP(i,N){
cin>>a;
A.push_back(a);
sum+=a;
}
LL suke=0;
FOR(i,0,N-1){
suke+=A[i];
minabs=min(minabs,abs(suke-(sum-suke)));
}
cout<<minabs<<endl;
}
| a.cc:70:11: error: 'LONG_LONG_MAX' was not declared in this scope
70 | LL minabs=LONG_LONG_MAX;
| ^~~~~~~~~~~~~
|
s503602463 | p03659 | C++ | #include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i;
void solve(){
cin.tie(0);
ios::sync_with_stdio(false);
cin>>n;
ll ans = INF,X=0,x=0;
std::vector<ll> a[2000005];
rep(i,n) {
cin>>a[i];
X += a[i];
}
rep(i,n){
x += a[i];
if(i+1<n)minch(ans,abs(X-x*2));
}
cout<<ans<<endl;
}
int main(){
solve();
return 0;
}
| a.cc: In function 'void solve()':
a.cc:120:8: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'std::vector<long long int>')
120 | cin>>a[i];
| ~~~^~~~~~
| | |
| | std::vector<long long int>
| std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from a.cc:32:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:24: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'bool&'
170 | operator>>(bool& __n)
| ~~~~~~^~~
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]'
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:25: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'short int&'
174 | operator>>(short& __n);
| ~~~~~~~^~~
/usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
177 | operator>>(unsigned short& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:177:34: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'short unsigned int&'
177 | operator>>(unsigned short& __n)
| ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]'
181 | operator>>(int& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:181:23: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'int&'
181 | operator>>(int& __n);
| ~~~~~^~~
/usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
184 | operator>>(unsigned int& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:184:32: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'unsigned int&'
184 | operator>>(unsigned int& __n)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
188 | operator>>(long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:188:24: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'long int&'
188 | operator>>(long& __n)
| ~~~~~~^~~
/usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
192 | operator>>(unsigned long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:192:33: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'long unsigned int&'
192 | operator>>(unsigned long& __n)
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
199 | operator>>(long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:199:29: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'long long int&'
199 | operator>>(long long& __n)
| ~~~~~~~~~~~^~~
/usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
203 | operator>>(unsigned long long& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:203:38: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'long long unsigned int&'
203 | operator>>(unsigned long long& __n)
| ~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
219 | operator>>(float& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:219:25: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'float&'
219 | operator>>(float& __f)
| ~~~~~~~^~~
/usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
223 | operator>>(double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:223:26: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'double&'
223 | operator>>(double& __f)
| ~~~~~~~~^~~
/usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
227 | operator>>(long double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:227:31: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'long double&'
227 | operator>>(long double& __f)
| ~~~~~~~~~~~~~^~~
/usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
328 | operator>>(void*& __p)
| ^~~~~~~~
/usr/include/c++/14/istream:328:25: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'void*&'
328 | operator>>(void*& __p)
| ~~~~~~~^~~
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:36: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'}
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]'
126 | operator>>(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:126:32: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
126 | operator>>(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/istream:133:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
133 | operator>>(ios_base& (*__pf)(ios_base&))
| ^~~~~~~~
/usr/include/c++/14/istream:133:30: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'std::ios_base& (*)(std::ios_base&)'
133 | operator>>(ios_base& (*__pf)(ios_base&))
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/istream:352:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(__streambuf_type*) [with _CharT = char; _Traits = std::char_traits<char>; __streambuf_type = std::basic_streambuf<char>]'
352 | operator>>(__streambuf_type* __sb);
| ^~~~~~~~
/usr/include/c++/14/istream:352:36: note: no known conversion for argument 1 from 'std::vector<long long int>' to 'std::basic_istream<char>::__streambuf_type*' {aka 'std::basic_streambuf<char>*'}
352 | operator>>(__streambuf_type* __sb);
| ~~~~~~~~~~~~~~~~~~^~~~
In file included from a.cc:12:
/us |
s853785036 | p03659 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
int main()
{
long long N;
cin >> N;
vector<long long> sumVec(N, 0);
long long a;
cin >> a;
sumVec.[0] = a;
long long total = a;
for (long long i = 1; i < N; i++)
{
cin >> a;
sumVec.[i] = a + sumVec[i - 1];
total += a;
}
long long ans = LLONG_MAX;
for (long long i = 0; i < N - 1; i++)
{
ans = min(ans, abs(sumVec[i] - (total - sumVec[i])));
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:17:12: error: expected unqualified-id before '[' token
17 | sumVec.[0] = a;
| ^
a.cc:24:16: error: expected unqualified-id before '[' token
24 | sumVec.[i] = a + sumVec[i - 1];
| ^
|
s116795218 | p03659 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
vector<long long> sumVec;
long long N;
cin >> N;
long long a;
cin >> a;
sumVec.push_back(a);
for (long long i = 1; i < N; i++)
{
cin >> a;
sumVec.push_back(a + sumVec[i - 1]);
}
long long ans = 1 << 29;
for (long long i = 0; i < N - 1; i++)
{
ans = min(ans, abs(sumVec[i] - (sumVec[i] - sumVec[N - 1]));
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:27:69: error: expected ')' before ';' token
27 | ans = min(ans, abs(sumVec[i] - (sumVec[i] - sumVec[N - 1]));
| ~ ^
| )
|
s581850374 | p03659 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
vector<long long> sumVec;
long long N;
cin >> N;
long long a;
cin >> a;
sumVec.push_back(a);
for (long long i = 1; i < N; i++)
{
cin >> a;
sumVec.push_back(a + sumVec[i - 1]);
}
long long ans = 1 << 29;
for (long long i = 0; i < N - 1; i++)
{
ans = min(ans, abs(sumVec[i] - sumVec[N - 1]))
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:27:55: error: expected ';' before '}' token
27 | ans = min(ans, abs(sumVec[i] - sumVec[N - 1]))
| ^
| ;
28 | }
| ~
|
s154668434 | p03659 | C++ | #define _CRT_SECURE_NO_WARNINGS
#define __STDC_FORMAT_MACROS
#include <algorithm>
#include <cinttypes>
#include <cstdio>
#include <cstdlib>
#include <vector>
using namespace std;
template<class T> void gc(T &x)
{
char c;
int s = 0;
x = 0;
c = getgetchar_unlocked();
if (c == '-') s = 1;
else if ('0' <= c && c <= '9') x = c - '0';
while (true)
{
c = getchar_unlocked();
if (c < '0' || c > '9') break;
x = x * 10 + (c - '0');
}
if (s) x = -x;
}
int main()
{
int N;
gc(N);
int tmp;
int64_t ttl = 0;
vector<int> a(N);
for (int i = 0; i < N; i++)
{
gc(tmp);
a[i] = tmp;
ttl += tmp;
}
int64_t now = 0;
int64_t mn = INT64_MAX;
for (int i = 0; i < N; i++)
{
now += a[i];
mn = min(mn, abs(ttl - 2 * now));
}
printf("%" PRId64 "\n", mn);
return 0;
}
| a.cc: In function 'void gc(T&)':
a.cc:17:9: error: there are no arguments to 'getgetchar_unlocked' that depend on a template parameter, so a declaration of 'getgetchar_unlocked' must be available [-fpermissive]
17 | c = getgetchar_unlocked();
| ^~~~~~~~~~~~~~~~~~~
a.cc:17:9: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated)
a.cc: In instantiation of 'void gc(T&) [with T = int]':
a.cc:37:7: required from here
37 | gc(N);
| ~~^~~
a.cc:17:28: error: 'getgetchar_unlocked' was not declared in this scope; did you mean 'getchar_unlocked'?
17 | c = getgetchar_unlocked();
| ~~~~~~~~~~~~~~~~~~~^~
| getchar_unlocked
|
s703698855 | p03659 | C++ | #define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<string.h>
#include<algorithm>
#include<numeric>
using namespace std;
int main() {
int N = 0;
vector <long long> a;
long long mi = 0;
cin >> N;
for (int i = 0; i<N; i++) {
long long num = 0;
cin >> num;
a.push_back(num);
}
mi = abs(a[0] - accumulate(a.begin()+1, a.end(), 0));
for (int i = 0; i<N; i++) {
if (i == 0) {
if (mi >= abs(a[0] - accumulate(a.begin() + 1, a.end(), 0))) {
mi = abs(a[0] - (int)accumulate(a.begin()+1, a.end(), 0));
}
}
else {
if (mi > abs(accumulate(a.begin(), a.begin() + i, 0) - accumulate(a.begin()+i, a.end(), 0))) {
mi = abs(accumulate(a.begin(), a.begin() + i, 0) - accumulate(a.begin()+i, a.end(), 0));
}
}
}
cout << mi << endl;
return 0;
} | a.cc:2:1: error: extended character is not valid in an identifier
2 |
| ^
a.cc:12:1: error: extended character is not valid in an identifier
12 |
| ^
a.cc:13:1: error: extended character is not valid in an identifier
13 |
| ^
a.cc:20:1: error: extended character is not valid in an identifier
20 |
| ^
a.cc:28:1: error: extended character is not valid in an identifier
28 |
| ^
a.cc:40:1: error: extended character is not valid in an identifier
40 |
| ^
a.cc:53:1: error: extended character is not valid in an identifier
53 |
| ^
a.cc:55:1: error: extended character is not valid in an identifier
55 |
| ^
a.cc:57:1: error: extended character is not valid in an identifier
57 |
| ^
a.cc:58:1: error: extended character is not valid in an identifier
58 |
| ^
a.cc:2:1: error: '\U000000a0' does not name a type
2 |
| ^
In file included from /usr/include/wchar.h:53,
from /usr/include/c++/14/cwchar:44,
from /usr/include/c++/14/bits/postypes.h:40,
from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:4:
/usr/include/x86_64-linux-gnu/bits/types/mbstate_t.h:6:9: error: '__mbstate_t' does not name a type
6 | typedef __mbstate_t mbstate_t;
| ^~~~~~~~~~~
/usr/include/wchar.h:104:59: error: 'size_t' has not been declared
104 | const wchar_t *__restrict __src, size_t __n)
| ^~~~~~
/usr/include/wchar.h:109:8: error: 'size_t' does not name a type
109 | extern size_t wcslcpy (wchar_t *__restrict __dest,
| ^~~~~~
/usr/include/wchar.h:61:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
60 | # include <bits/types/locale_t.h>
+++ |+#include <cstddef>
61 | #endif
/usr/include/wchar.h:115:8: error: 'size_t' does not name a type
115 | extern size_t wcslcat (wchar_t *__restrict __dest,
| ^~~~~~
/usr/include/wchar.h:115:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:126:59: error: 'size_t' has not been declared
126 | const wchar_t *__restrict __src, size_t __n)
| ^~~~~~
/usr/include/wchar.h:133:63: error: 'size_t' has not been declared
133 | extern int wcsncmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
| ^~~~~~
/usr/include/wchar.h:142:25: error: 'size_t' has not been declared
142 | size_t __n) __THROW;
| ^~~~~~
/usr/include/wchar.h:150:27: error: 'size_t' has not been declared
150 | size_t __n, locale_t __loc) __THROW;
| ^~~~~~
/usr/include/wchar.h:159:8: error: 'size_t' does not name a type
159 | extern size_t wcsxfrm (wchar_t *__restrict __s1,
| ^~~~~~
/usr/include/wchar.h:159:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:174:8: error: 'size_t' does not name a type
174 | extern size_t wcsxfrm_l (wchar_t *__s1, const wchar_t *__s2,
| ^~~~~~
/usr/include/wchar.h:174:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:212:8: error: 'size_t' does not name a type
212 | extern size_t wcscspn (const wchar_t *__wcs, const wchar_t *__reject)
| ^~~~~~
/usr/include/wchar.h:212:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:216:8: error: 'size_t' does not name a type
216 | extern size_t wcsspn (const wchar_t *__wcs, const wchar_t *__accept)
| ^~~~~~
/usr/include/wchar.h:216:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:247:8: error: 'size_t' does not name a type
247 | extern size_t wcslen (const wchar_t *__s) __THROW __attribute_pure__;
| ^~~~~~
/usr/include/wchar.h:247:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:265:8: error: 'size_t' does not name a type
265 | extern size_t wcsnlen (const wchar_t *__s, size_t __maxlen)
| ^~~~~~
/usr/include/wchar.h:265:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:272:59: error: 'size_t' has not been declared
272 | extern "C++" wchar_t *wmemchr (wchar_t *__s, wchar_t __c, size_t __n)
| ^~~~~~
/usr/include/wchar.h:275:38: error: 'size_t' has not been declared
275 | size_t __n)
| ^~~~~~
/usr/include/wchar.h:283:63: error: 'size_t' has not been declared
283 | extern int wmemcmp (const wchar_t *__s1, const wchar_t *__s2, size_t __n)
| ^~~~~~
/usr/include/wchar.h:288:58: error: 'size_t' has not been declared
288 | const wchar_t *__restrict __s2, size_t __n) __THROW;
| ^~~~~~
/usr/include/wchar.h:292:63: error: 'size_t' has not been declared
292 | extern wchar_t *wmemmove (wchar_t *__s1, const wchar_t *__s2, size_t __n)
| ^~~~~~
/usr/include/wchar.h:296:53: error: 'size_t' has not been declared
296 | extern wchar_t *wmemset (wchar_t *__s, wchar_t __c, size_t __n) __THROW;
| ^~~~~~
/usr/include/wchar.h:302:59: error: 'size_t' has not been declared
302 | const wchar_t *__restrict __s2, size_t __n)
| ^~~~~~
/usr/include/wchar.h:317:27: error: 'mbstate_t' does not name a type
317 | extern int mbsinit (const mbstate_t *__ps) __THROW __attribute_pure__;
| ^~~~~~~~~
/usr/include/wchar.h:321:8: error: 'size_t' does not name a type
321 | extern size_t mbrtowc (wchar_t *__restrict __pwc,
| ^~~~~~
/usr/include/wchar.h:321:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:326:8: error: 'size_t' does not name a type
326 | extern size_t wcrtomb (char *__restrict __s, wchar_t __wc,
| ^~~~~~
/usr/include/wchar.h:326:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:330:8: error: 'size_t' does not name a type
330 | extern size_t __mbrlen (const char *__restrict __s, size_t __n,
| ^~~~~~
/usr/include/wchar.h:330:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:332:8: error: 'size_t' does not name a type
332 | extern size_t mbrlen (const char *__restrict __s, size_t __n,
| ^~~~~~
/usr/include/wchar.h:332:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:362:8: error: 'size_t' does not name a type
362 | extern size_t mbsrtowcs (wchar_t *__restrict __dst,
| ^~~~~~
/usr/include/wchar.h:362:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:368:8: error: 'size_t' does not name a type
368 | extern size_t wcsrtombs (char *__restrict __dst,
| ^~~~~~
/usr/include/wchar.h:368:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:376:8: error: 'size_t' does not name a type
376 | extern size_t mbsnrtowcs (wchar_t *__restrict __dst,
| ^~~~~~
/usr/include/wchar.h:376:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:382:8: error: 'size_t' does not name a type
382 | extern size_t wcsnrtombs (char *__restrict __dst,
| ^~~~~~
/usr/include/wchar.h:382:8: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/wchar.h:396:42: error: 'size_t' has not been declared
396 | extern int wcswidth (const wchar_t *__s, size_t __n) __THROW;
| ^~~~~~
/usr/include/wchar.h:695:59: error: 'size_t' has not been declared
695 | const wchar_t *__restrict __src, size_t __n)
| ^~~~~~
/usr/include/wchar.h:718:8: error: '__FILE' does not name a type; did you mean 'EMFILE'?
718 | extern __FILE *open_wmemstream (wchar_t **__bufloc, size_t *__sizeloc) __THROW
| ^~~~~~
| EMFILE
/usr/include/wchar.h:725:19: error: '__FILE' was not declared in this scope; did you mean 'EMFILE'?
725 | extern int fwide (__FILE *__fp, int __mode) __THROW;
| ^~~~~~
| EMFILE
/usr/include/wchar.h:725:27: error: '__fp' was not declared in this scope
725 | extern int fwide (__FILE *__fp, int __mode) __THROW;
| ^~~~
/usr/include/wchar.h:725:33: error: expected primary-expression before 'int'
725 | extern int fwide (__FILE *__fp, int __mode) __THROW;
| ^~~
/usr/include/wchar.h:725:43: error: expression list treated as compound expression in initializer [-fpermissive]
725 | extern |
s503797766 | p03659 | C++ | #include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <limits>
using namespace std;
inline void amin(int &x,int y)
{
if ( y < x ) {
x = y;
}
}
int main()
{
int N;//,a;
long long sum[200001];
sum[0] = 0;
long long min_num = 2 * 10000000000;//pow(10, 9.0);
cin >> N;
for (int i = 1; i <= N; i++) {
//cin >> a;
cin >> sum[i];
sum[i] += sum[i - 1];// + a;
}
for ( int i = 1; i < N; i++) {
//min_num = min(min_num, abs(sum[N] - (2 * sum[i])));
admin(min_num, abs(sum[N] - (2 * sum[i)));
}
cout << min_num << '\n';
} | a.cc: In function 'int main()':
a.cc:33:47: error: expected ']' before ')' token
33 | admin(min_num, abs(sum[N] - (2 * sum[i)));
| ^
| ]
a.cc:33:9: error: 'admin' was not declared in this scope; did you mean 'amin'?
33 | admin(min_num, abs(sum[N] - (2 * sum[i)));
| ^~~~~
| amin
|
s852866811 | p03659 | C++ | #include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <limits>
using namespace std;
int main()
{
int N;//,a;
long long sum[200001];
sum[0] = 0;
long long min_num = LLONG_MAX;//2 * 10000000000;//pow(10, 9.0);
cin >> N;
for (int i = 1; i <= N; i++) {
//cin >> a;
cin >> sum[i];
sum[i] += sum[i - 1];// + a;
}
for ( int i = 1; i < N; i++) {
min_num = min(min_num, abs(sum[N] - (2 * sum[i])));
}
cout << min_num << '\n';
} | a.cc: In function 'int main()':
a.cc:15:25: error: 'LLONG_MAX' was not declared in this scope
15 | long long min_num = LLONG_MAX;//2 * 10000000000;//pow(10, 9.0);
| ^~~~~~~~~
a.cc:6:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
5 | #include <vector>
+++ |+#include <climits>
6 | #include <limits>
|
s151714389 | p03659 | C++ | #include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
ll ans = LLONG_MAX;
ll a_sum = 0;
VL v;
cin >> n;
REP(i, n){
ll a;
cin >> a;
a_sum += a;
if(i == n - 1) break;
v.push_back(a_sum);
}
REP(i, v.size()){
ans = min(abs(a_sum - 2 * v[i]), ans);
}
cout << ans << "\n";
return 0;
}
| a.cc: In function 'int main()':
a.cc:33:14: error: 'LLONG_MAX' was not declared in this scope
33 | ll ans = LLONG_MAX;
| ^~~~~~~~~
a.cc:13:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
12 | #include <algorithm>
+++ |+#include <climits>
13 | using namespace std;
|
s683247209 | p03659 | Java | import java.util.Scanner;
public class C {
public static int absDifference(int x, int[] cards) {
int sumx = 0;
int sumy = 0;
int n = cards.length;
for (int i = 0; i < x; i++) {
sumx += cards[i];
}
for (int i = 0; i < n-x; i++) {
sumy += cards[n-i-1];
}
return Math.abs(sumx - sumy);
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] cards = new int[n];
for (int i = 0; i < n; i++) {
cards[i] = sc.nextInt();
}
sc.close();
int ans = 100000000;
for (int i = 1; i < n; i++) {
int temp = absDifference(i, cards);
if (temp <= ans) {
ans = temp;
}
}
System.out.println(ans);
}
} | Main.java:3: error: class C is public, should be declared in a file named C.java
public class C {
^
1 error
|
s256417914 | p03659 | C++ |
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
int N;
int input,total[200010]={0};
int answer=INT_MAX;
cin >> N;
for(int i=1;i<=N;i++){
cin >> input;
total[i]=total[i-1]+input;
// cout << total[i] << endl;
}
for(int i=1;i<N;i++){
answer=min(int(answer),abs(total[i]-(total[N]-total[i])));
}
cout << answer << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:9:20: error: 'INT_MAX' was not declared in this scope
9 | int answer=INT_MAX;
| ^~~~~~~
a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
3 | #include <algorithm>
+++ |+#include <climits>
4 | using namespace std;
|
s718304599 | p03659 | C++ | //El Lool
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <fstream>
#include <cctype>
#include <string>
#include <string.h>
#include <vector>
#include <sstream>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define sz(v) ((int)((v).size()))
void fast()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
string cop(vector<char>v)
{
string x;
for (int i = 0; i < sz(v); i++)
x += v[i];
return x;
}
int main()
{
fast();
int t, n, w;
long long sum = 0, min = LONG_MAX;
vector<long long>v;
string s;
t=1;
while (t--)
{
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> w;
sum += w;
v.push_back(sum);
}
for (int i = 0; i < v.size() - 1; i++)
{
long long x = v[i];
long long y = sum - v[i];
if (abs(x-y) < min)
min = abs(x-y);
}
cout << min << endl;
min = 1e18;
v.clear();
sum = 0;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:37:34: error: 'LONG_MAX' was not declared in this scope
37 | long long sum = 0, min = LONG_MAX;
| ^~~~~~~~
a.cc:16:1: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
15 | #include <set>
+++ |+#include <climits>
16 | using namespace std;
|
s414680278 | p03659 | C++ | //El Lool
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <fstream>
#include <cctype>
#include <string>
#include <string.h>
#include <vector>
#include <sstream>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define sz(v) ((int)((v).size()))
void fast()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
string cop(vector<char>v)
{
string x;
for (int i = 0; i < sz(v); i++)
x += v[i];
return x;
}
int main()
{
fast();
int t, n, w;
long long sum = 0, min = LONG_MAX;
vector<long long>v;
string s;
t=1
while (t--)
{
cin >> n;
for (int i = 0; i < n; i++)
{
cin >> w;
sum += w;
v.push_back(sum);
}
for (int i = 0; i < v.size() - 1; i++)
{
long long x = v[i];
long long y = sum - v[i];
if (abs(x-y) < min)
min = abs(x-y);
}
cout << min << endl;
min = 1e18;
v.clear();
sum = 0;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:37:34: error: 'LONG_MAX' was not declared in this scope
37 | long long sum = 0, min = LONG_MAX;
| ^~~~~~~~
a.cc:16:1: note: 'LONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
15 | #include <set>
+++ |+#include <climits>
16 | using namespace std;
a.cc:40:12: error: expected ';' before 'while'
40 | t=1
| ^
| ;
41 |
42 | while (t--)
| ~~~~~
|
s628980759 | p03659 | C++ | #include"bits/stdc++.h"
using namespace std;
using ll=long long
void solve();
ll sum(ll,ll);
ll n;
vector<ll> a;
vector<ll> s;
int main(){
solve();
return 0;
}
void solve(){
cin >>n;
a.resize(n+1);
s.resize(n+1);
a[0]=0;
s[0]=a[0];
for(ll i=1;i<=n;i++){
cin >>a[i];
s[i]=s[i-1]+a[i];
}
ll ans=1e18;
for(ll i=1;i<n;i++){
ans=min(ans,abs(sum(1,i)-sum(i+1,n)));
}
cout <<ans <<endl;
}
ll sum(ll l,ll r){
return s[r]-s[l-1];
} | a.cc:3:15: error: 'long long' specified with 'void'
3 | using ll=long long
| ^~~~
a.cc:4:5: error: expected ';' before 'solve'
4 | void solve();
| ^~~~~~
| ;
a.cc:5:1: error: 'll' does not name a type
5 | ll sum(ll,ll);
| ^~
a.cc:7:1: error: 'll' does not name a type
7 | ll n;
| ^~
a.cc:8:8: error: 'll' was not declared in this scope
8 | vector<ll> a;
| ^~
a.cc:8:10: error: template argument 1 is invalid
8 | vector<ll> a;
| ^
a.cc:8:10: error: template argument 2 is invalid
a.cc:9:8: error: 'll' was not declared in this scope
9 | vector<ll> s;
| ^~
a.cc:9:10: error: template argument 1 is invalid
9 | vector<ll> s;
| ^
a.cc:9:10: error: template argument 2 is invalid
a.cc: In function 'int main()':
a.cc:12:9: error: 'solve' was not declared in this scope
12 | solve();
| ^~~~~
a.cc: In function 'void solve()':
a.cc:16:15: error: 'n' was not declared in this scope; did you mean 'yn'?
16 | cin >>n;
| ^
| yn
a.cc:17:11: error: request for member 'resize' in 'a', which is of non-class type 'int'
17 | a.resize(n+1);
| ^~~~~~
a.cc:18:11: error: request for member 'resize' in 's', which is of non-class type 'int'
18 | s.resize(n+1);
| ^~~~~~
a.cc:19:10: error: invalid types 'int[int]' for array subscript
19 | a[0]=0;
| ^
a.cc:20:10: error: invalid types 'int[int]' for array subscript
20 | s[0]=a[0];
| ^
a.cc:20:15: error: invalid types 'int[int]' for array subscript
20 | s[0]=a[0];
| ^
a.cc:21:13: error: 'll' was not declared in this scope
21 | for(ll i=1;i<=n;i++){
| ^~
a.cc:21:20: error: 'i' was not declared in this scope
21 | for(ll i=1;i<=n;i++){
| ^
a.cc:26:9: error: 'll' was not declared in this scope
26 | ll ans=1e18;
| ^~
a.cc:27:15: error: expected ';' before 'i'
27 | for(ll i=1;i<n;i++){
| ^~
| ;
a.cc:27:20: error: 'i' was not declared in this scope
27 | for(ll i=1;i<n;i++){
| ^
a.cc:28:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
28 | ans=min(ans,abs(sum(1,i)-sum(i+1,n)));
| ^~~
| abs
a.cc:28:33: error: 'sum' was not declared in this scope
28 | ans=min(ans,abs(sum(1,i)-sum(i+1,n)));
| ^~~
a.cc:30:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
30 | cout <<ans <<endl;
| ^~~
| abs
a.cc: At global scope:
a.cc:33:1: error: 'll' does not name a type
33 | ll sum(ll l,ll r){
| ^~
|
s184088806 | p03659 | C++ | #include <bits/stdc++.h>
using namespace std;
int main () {
int n;
cin >> n;
long long a[200005];
for (int i=1;i<=n;i++) cin >> a[i];
long long sum=0;
for (int i=1;i<=n;i++) {
sum+=a[i];
}
a[0]=0;
for (int i=1;i<=n;i++) {
a[i]+=a[i-1];
}
int ans=2000000007;
for (int i=1;i<n;i++) {
ans=min(ans,abs(a[i]-(sum-a[i])));
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:20:24: error: no matching function for call to 'min(int&, long long int)'
20 | ans=min(ans,abs(a[i]-(sum-a[i])));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:20:24: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
20 | ans=min(ans,abs(a[i]-(sum-a[i])));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:20:24: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
20 | ans=min(ans,abs(a[i]-(sum-a[i])));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
|
s955430273 | p03659 | C++ | #include <cstdio>
#define LL long long
#define INF 0x3f3f3f3f3f
int cards[200005];
int n;
LL sum_all;
LL sum;
LL abs(LL x){
if(x < 0) x = -x;
return x;
}
int main(){
scanf("%d", &n);
for(int i = 0; i < n; i++){
scanf("%d", &(cards[i]));
}
sum_all = 0;
for(int i = 0 ; i < n; i++){
sum_all += cards[i];
}
sum = 0;
LL take = 0; LL min = INF; LL min_take;
for(int i = 0; i < n; i++){
LL diff = abs( sum_all - sum - sum);
if( min > diff ){
min = diff;
min_take = take;
}
sum += cards[i];
take ++;
}
LL diff = abs( sum_all - | a.cc: In function 'int main()':
a.cc:34:28: error: expected primary-expression at end of input
34 | LL diff = abs( sum_all -
| ^
a.cc:34:28: error: expected '}' at end of input
a.cc:13:11: note: to match this '{'
13 | int main(){
| ^
|
s385828238 | p03659 | C++ | #include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main(){
int N, su_sum, ta_sum;
cin >> N;
vector<int> a(N), dif(N-1);
for(int i = 0; i < N; i++) cin >> a[i];
/*/
すぬけの引く数を1〜Nまで変化させて、そのときのx-yを記録
記録した配列をソートして、最小値を出力
/*/
//1〜Nまで変化させるループ(iで進める)
for(int i = 0; i < N-1; i++){
su_sum = 0;
ta_sum = 0;
//すぬけの合計値(0~iまで)を求めるためのループ
for(int j = 0; j < i+1; j++){
su_sum += a[j];
}
//たぬきの合計値(i+1 ~ N-1まで)を求めるループ
for(int j = i+1; j < N; j++){
ta_sum += a[j];
}
//x-yを格納
dif[i] = abs(su_sum - ta_sum);
}
sort(dif.begin(),dif.end());
cout << dif[0] << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:35:3: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
35 | sort(dif.begin(),dif.end());
| ^~~~
| sqrt
|
s250374358 | p03659 | C++ | #include <iostream>
#include <cstdio>
using namespace std;
vector<int> v;
#define pb push_back
int main()
{
int N; cin >> N;
for(int i = 0; i < N; i++) cin >> v[i];
int min = 2e5;
for(int i = 1; i < N; i++)
{
if(abs(v[i] - v[i-1]) < min) min = abs(v[i] - v[i-1];
}
cout << min << endl;
}
| a.cc:6:1: error: 'vector' does not name a type
6 | vector<int> v;
| ^~~~~~
a.cc: In function 'int main()':
a.cc:13:43: error: 'v' was not declared in this scope
13 | for(int i = 0; i < N; i++) cin >> v[i];
| ^
a.cc:19:24: error: 'v' was not declared in this scope
19 | if(abs(v[i] - v[i-1]) < min) min = abs(v[i] - v[i-1];
| ^
|
s087792939 | p03659 | C++ | #include <bits/stdc++.h>
using namespace std;
vector<int> v;
#define pb push_back
int main()
{
int N; cin >> N;
for(int i = 0; i < N; i++) cin >> v[i];
int min = 2e5;
for(int i = 1; i < N; i++)
{
if(abs(v[i] - v[i-1]) < min) min = abs(v[i] - v[i-1];
}
cout << min << endl;
}
| a.cc: In function 'int main()':
a.cc:18:69: error: expected ')' before ';' token
18 | if(abs(v[i] - v[i-1]) < min) min = abs(v[i] - v[i-1];
| ~ ^
| )
|
s352063833 | p03659 | C++ | #include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<vector>
#include<algorithm>
long long int abs(long long int a){
if(a>=0)return a;
else return -a;
}
#define max 200005
long long int fo[max],re[max],sum[max];
using namespace std;
int main(){
int n;
scanf("%d",&n);
int a[n],i;
for(i=0;i<=n-1;i++)scanf("%d",&a[i]);
for(i=0;i<=n-1;i++){
if(i==0)fo[i]=a[i];
else fo[i]=fo[i-1]+a[i];
}
for(i=n-1;i>=0;i--){
if(i==n-1)re[i]=-a[i];
else re[i]=re[i+1]-a[i];
}
for(i=0;i<=n-2;i++){
sum[i]=abs(fo[i]+re[i+1]);
}
sort(sum,sum+n-1);
printf("%lld",sum[0]);
return 0;
}
| a.cc:8:34: error: 'long long int abs(long long int)' conflicts with a previous declaration
8 | long long int abs(long long int a){
| ^
In file included from /usr/include/c++/14/cstdlib:81,
from /usr/include/c++/14/stdlib.h:36,
from a.cc:3:
/usr/include/c++/14/bits/std_abs.h:61:3: note: previous declaration 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
a.cc: In function 'int main()':
a.cc:30:19: error: call of overloaded 'abs(long long int)' is ambiguous
30 | sum[i]=abs(fo[i]+re[i+1]);
| ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
/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:8:15: note: candidate: 'long long int abs(long long int)'
8 | long long int abs(long long int a){
| ^~~
|
s594580229 | p03659 | C++ | #include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<vector>
#include<algorithm>
long long int abs(long long int a){
if(a>=0)return a;
else return -a;
}
#define max 200005
long long int fo[max],re[max],sum[max];
using namespace std;
int main(){
int n;
scanf("%d",&n);
int a[n],i;
for(i=0;i<=n-1;i++)scanf("%d",&a[i]);
for(i=0;i<=n-1;i++){
if(i==0)fo[i]=a[i];
else fo[i]=fo[i-1]+a[i];
}
for(i=n-1;i>=0;i--){
if(i==n-1)re[i]=-a[i];
else re[i]=re[i+1]-a[i];
}
for(i=0;i<=n-2;i++){
sum[i]=abs(fo[i]+re[i+1]);
}
sort(sum,sum+n-1);
printf("%lld",sum[0]);
return 0;
}
| a.cc:8:34: error: 'long long int abs(long long int)' conflicts with a previous declaration
8 | long long int abs(long long int a){
| ^
In file included from /usr/include/c++/14/cstdlib:81,
from /usr/include/c++/14/stdlib.h:36,
from a.cc:3:
/usr/include/c++/14/bits/std_abs.h:61:3: note: previous declaration 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
a.cc: In function 'int main()':
a.cc:30:19: error: call of overloaded 'abs(long long int)' is ambiguous
30 | sum[i]=abs(fo[i]+re[i+1]);
| ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
/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:8:15: note: candidate: 'long long int abs(long long int)'
8 | long long int abs(long long int a){
| ^~~
|
s047116614 | p03659 | C | #include<stdio.h>
int main(){
long long x[100010], sum=0LL;
long long res, ans=10000000000000LL, a, n;
int i, j;
if(scanf("%lld", &n)==1){
for(i=0; i<n; i++){
if(scanf("%ld", &a)==1){
sum+=a;
if(i==0){
x[i]=a;
}
}
for(i=0; i<n-1; i++){
res=sum-2*x[i];
if(res<0){
res*=-1;
}
if(res<ans && i+1<n){
ans=res;
}
}
printf("%lld\n", ans);
}
return 0;
}
| main.c: In function 'main':
main.c:33:1: error: expected declaration or statement at end of input
33 | }
| ^
|
s938236737 | p03659 | C++ | //
// main.cpp
// CODE 2
//
// Created by Parsa Mrezaei on 7/13/17.
// Copyright © 2017 Parsa Mrezaei. All rights reserved.
//
#include <iostream>
#include <set>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <unordered_set>
#include <stdio.h>
using namespace std;
const int MAXN = 3e5;
int arr[MAXN];
int main () {
int n; cin >> n;
long long sum = 0;
for (int i = 0; i < n; sum += arr[i++])
cin >> arr[i];
if (n == 2)
return cout << abs(arr[0] - arr[1]) << endl, 0;
long long mn = LLONG_MAX;
long long sumtilnow = arr[0];
for (int i = 1; i < n - 1; sumtilnow += arr[i++]) {
long long now = abs(sum - sumtilnow);
cout << i << " " << sumtilnow << " " << now << endl;
mn = min(mn, abs(sumtilnow - now));
}
cout << mn << endl;
}
| a.cc: In function 'int main()':
a.cc:31:20: error: 'LLONG_MAX' was not declared in this scope
31 | long long mn = LLONG_MAX;
| ^~~~~~~~~
a.cc:16:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
15 | #include <unordered_set>
+++ |+#include <climits>
16 | #include <stdio.h>
|
s969182537 | p03659 | C++ | #include<iostream>
using namespace std;int main(){long long int a[200000],mini=100000000000,n,sum1=0,sum2=0;cin>>n;for(int i=0;i<n;i++){cin>>a[i];sum1+=a[i];
for(int i=n-1;0<i;i--){sum1-=a[i];sum2+=a[i];if(abs(sum1-sum2)<mini){mini=abs(sum1-sum2);}}cout<<mini<<endl;return 0;} | a.cc: In function 'int main()':
a.cc:3:127: error: expected '}' at end of input
3 | for(int i=n-1;0<i;i--){sum1-=a[i];sum2+=a[i];if(abs(sum1-sum2)<mini){mini=abs(sum1-sum2);}}cout<<mini<<endl;return 0;}
| ^
a.cc:2:31: note: to match this '{'
2 | using namespace std;int main(){long long int a[200000],mini=100000000000,n,sum1=0,sum2=0;cin>>n;for(int i=0;i<n;i++){cin>>a[i];sum1+=a[i];
| ^
|
s654728277 | p03659 | C++ | #include<iostream>
using namespace std;int main(){long long int a[200000],mini=100000000000,n,sum1=0,sum2=0;cin>>n;for(int i=0;i<n;i++){cin>>a[i];sum1+=a[i];for(int i=n-1;0<i;i--){sum1-=a[i];sum2+=a[i];if(abs(sum1-sum2)<mini){mini=abs(sum1-sum2);}}cout<<mini<<endl;return 0;} | a.cc: In function 'int main()':
a.cc:2:257: error: expected '}' at end of input
2 | using namespace std;int main(){long long int a[200000],mini=100000000000,n,sum1=0,sum2=0;cin>>n;for(int i=0;i<n;i++){cin>>a[i];sum1+=a[i];for(int i=n-1;0<i;i--){sum1-=a[i];sum2+=a[i];if(abs(sum1-sum2)<mini){mini=abs(sum1-sum2);}}cout<<mini<<endl;return 0;}
| ~ ^
|
s336467993 | p03659 | C++ | #define inf 1000000000UL
#define v_all v.begin(),v.end()
#define vi vector<long long>
#define ll long long
#include<cstdlib> //abs()
#include<algorithm>
#include<vector>
#include<iostream>
using namespace std;
int main(){
ll n;
cin>>n;
vi v(n);
ll max=0;
for(int i=0;i<n;i++){
cin>>v[i];
max+=v[i];
}
ll ans=inf;
ll m[n]={0};
auto add=[&v,&m](int x){
ll ans=0;
if(m[x-1]==0){
for(int i=0;i<x;i++){
ans+=v[i];
//cout<<"ans in 1:"<<ans<<"x:"<<x<<endl;
}
m[x]=ans;
}else{
ans=v[x-1]+m[x-1];
//cout<<"ans in 2:"<<ans<<"x:"<<x<<endl;
m[x]=ans;
}
return ans;
};
//sort(v_all);
for(int i=1;i<n;i++){
ans= min(abs(max-add(i)*2),ans);
//cout<<"i"<<i<<endl;
}
cout<<ans<<endl;
return 0;
}#define inf 1000000000UL
#define v_all v.begin(),v.end()
#define vi vector<long long>
#define ll long long
#include<cstdlib> //abs()
#include<algorithm>
#include<vector>
#include<iostream>
using namespace std;
int main(){
ll n;
cin>>n;
vi v(n);
ll max=0;
for(int i=0;i<n;i++){
cin>>v[i];
max+=v[i];
}
ll ans=inf;
ll m[n]={0};
auto add=[&v,&m](int x){
ll ans=0;
if(m[x-1]==0){
for(int i=0;i<x;i++){
ans+=v[i];
//cout<<"ans in 1:"<<ans<<"x:"<<x<<endl;
}
m[x]=ans;
}else{
ans=v[x-1]+m[x-1];
//cout<<"ans in 2:"<<ans<<"x:"<<x<<endl;
m[x]=ans;
}
return ans;
};
//sort(v_all);
for(int i=1;i<n;i++){
ans= min(abs(max-add(i)*2),ans);
//cout<<"i"<<i<<endl;
}
cout<<ans<<endl;
return 0;
} | a.cc:46:2: error: stray '#' in program
46 | }#define inf 1000000000UL
| ^
a.cc:46:3: error: 'define' does not name a type
46 | }#define inf 1000000000UL
| ^~~~~~
a.cc:58:5: error: redefinition of 'int main()'
58 | int main(){
| ^~~~
a.cc:13:5: note: 'int main()' previously defined here
13 | int main(){
| ^~~~
|
s402368141 | p03659 | C++ | #include <stdio.h>
#include <stdlib.h>
int main(void){
int n;
scanf("%d",&n);
double c[n];
scanf("%d",&c[0]);
double sum = 0;
for (int i = 1 ; i<n ; i++){
scanf("%d",&c[i]);
sum += c[i];
}
double sa = sum - c[0];
double min = fabs(sa);
for (int i = 1; i< n-1;i++){
sa -= c[i]*2;
if (min > fabs(sa)){
min = fabs(sa);
}
}
printf("%0.lf\n",min);
return (0);
} | a.cc: In function 'int main()':
a.cc:15:30: error: 'fabs' was not declared in this scope; did you mean 'labs'?
15 | double min = fabs(sa);
| ^~~~
| labs
|
s285977928 | p03659 | C++ | #include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<math.h>
#include<string.h>
#include<algorithm>
#define maxn 200005
#define ll long long
using namespace std;
vector<int>num;
int cmp(int a,int b)
{
if(abs(a)>=abs(b))
return 1;
return 0;
}
int used[maxn];
int main()
{
int n,tmp;
ll ans;
while(scanf("%d",&n)!=EOF)
{
num.clear();
ans=0;
if(n==)
while(n--)
{
cin>>tmp;
num.push_back(tmp);
}
sort(num.begin(),num.end(),cmp);
int len=num.size();
for(int i=0;i<len;i++)
{
if(ans>=0&&num[i]>=0||(ans<0&&num[i]<0))
ans-=num[i];
else ans+=num[i];
}
if(ans>=0)cout<<ans<<endl;
else cout<<-ans<<endl;
}
} | a.cc: In function 'int main()':
a.cc:28:23: error: expected primary-expression before ')' token
28 | if(n==)
| ^
|
s909779382 | p03659 | C++ | #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
LL num;
int n;
LL a[200005];
LL q[200005];
int main()
{
while(~scanf("%d",&n)){
LL sum = 0;
LL ans = 1LL << 60;
LL fir,sec;
for(int i = 1;i <= n;i++){
scanf("%I64d",&a[i]);
sum += a[i];
q[i] = q[i-1] + a[i];
}
if(n == 2)printf("%I64d\n",abs(a[1] - a[2]));
else{
for(int i = 1;i < n;i++)
{
fir = q[i];
sec = sum - q[i];
num = abs(fir - sec);
ans = min(ans,num);
}
printf("%I64d\n",ans);
}
memset(a,0,sizeof(a));
memset(q,0,sizeof(q));
}
}#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
LL num;
int n;
LL a[200005];
LL q[200005];
int main()
{
while(~scanf("%d",&n)){
LL sum = 0;
LL ans = 1LL << 60;
LL fir,sec;
for(int i = 1;i <= n;i++){
scanf("%I64d",&a[i]);
sum += a[i];
q[i] = q[i-1] + a[i];
}
if(n == 2)printf("%I64d\n",abs(a[1] - a[2]));
else{
for(int i = 1;i < n;i++)
{
fir = q[i];
sec = sum - q[i];
num = abs(fir - sec);
ans = min(ans,num);
}
printf("%I64d\n",ans);
}
memset(a,0,sizeof(a));
memset(q,0,sizeof(q));
}
} | a.cc:39:2: error: stray '#' in program
39 | }#include<cstdio>
| ^
a.cc:39:3: error: 'include' does not name a type
39 | }#include<cstdio>
| ^~~~~~~
a.cc:47:4: error: redefinition of 'LL num'
47 | LL num;
| ^~~
a.cc:9:4: note: 'LL num' previously declared here
9 | LL num;
| ^~~
a.cc:48:5: error: redefinition of 'int n'
48 | int n;
| ^
a.cc:10:5: note: 'int n' previously declared here
10 | int n;
| ^
a.cc:49:4: error: redefinition of 'LL a [200005]'
49 | LL a[200005];
| ^
a.cc:11:4: note: 'LL a [200005]' previously declared here
11 | LL a[200005];
| ^
a.cc:50:4: error: redefinition of 'LL q [200005]'
50 | LL q[200005];
| ^
a.cc:12:4: note: 'LL q [200005]' previously declared here
12 | LL q[200005];
| ^
a.cc:52:5: error: redefinition of 'int main()'
52 | int main()
| ^~~~
a.cc:14:5: note: 'int main()' previously defined here
14 | int main()
| ^~~~
|
s310427869 | p03659 | Java | 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
*/
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();
int[] a = new int[n];
long sum = 0;
for (int i = 0; i < n; ++i) {
a[i] = in.nextInt();
sum += a[i];
}
long tmp = 0, res = Integer.MAX_VALUE;
for (int i = n - 1; i >= 1; --i) {
tmp += a[i];
long curSum = sum - tmp;
res = Math.min(res, Math.abs(curSum - tmp));
}
out.println(res);
}
}
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() {
| Main.java:66: error: reached end of file while parsing
public int nextInt() {
^
1 error
|
s959076973 | p03659 | C++ | include <iostream>
#include <vector>
#include <math.h>
using namespace std;
int main() {
int N;
cin >> N;
vector<long long> data;
data.reserve(N);
int input;
long long total = 0;
for (int n = 0; n < N; n++) {
cin >> input;
total += input;
data.push_back(input);
}
long long x = data[0];
long long y = total - x;
int min = abs(x - y);
for (int n = 1; n < (N - 1); n++) {
x += data[n];
y -= data[n];
long long res = abs(x - y);
if (res < min) {
min = res;
}
}
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>
| |
s383550266 | p03659 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N;
cin >> N;
vector <long long int> cards (N);
long long int sum = 0;
long long int ans = LONG_MAX;
for(int i = 0; i < N; i++){
long long int z;
cin >> z;
if(i==0){
cards[i] = z;
}else{
cards[i] = (z+cards[i-1]);
}
sum = cards[i];
}
// cout << sum << "\n";
for(int i = 0; i < N-1; i++){
int a = cards[i];
int b = sum-a;
// cout << a << " " << b << "\n";
ans = min(ans, abs(a-b));
}
cout << ans << "\n";
return 0;
} | a.cc: In function 'int main()':
a.cc:26:18: error: no matching function for call to 'min(long long int&, int)'
26 | ans = min(ans, abs(a-b));
| ~~~^~~~~~~~~~~~~~~
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:26:18: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
26 | ans = min(ans, abs(a-b));
| ~~~^~~~~~~~~~~~~~~
/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:26:18: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
26 | ans = min(ans, abs(a-b));
| ~~~^~~~~~~~~~~~~~~
|
s251423606 | p03659 | C | #include <cstdio>
#include <cstdlib>
#include <climits>
long long int absll(long long int g){
return (g < 0)?g * -1:g;
}
int main(){
int N;
long long int a[200000];
long long int sn = 0,al = 0,ans;
scanf("%d\n",&N);
for(int i = 0;i < N;i++){
long long int buf;
scanf("%lld ",&buf);
a[i] = buf;
sn += buf;
}
al = a[N - 1];
sn -= a[N - 1];
ans = absll(sn - al);
for(int i = N - 2;i > 0;i--){
al += a[i];
sn -= a[i];
int g = absll(sn - al);
if(g < ans) ans = g;
}
printf("%lld\n",ans);
return 0;
} | main.c:1:10: fatal error: cstdio: No such file or directory
1 | #include <cstdio>
| ^~~~~~~~
compilation terminated.
|
s048766071 | p03659 | C++ | #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
typedef long long ll;
int main(void){
int N;
cin>>N;
vector<ll> a(N),b(N);
rep(i,N){
cin>>a[i];
}
rep(i,N-1){
sum += a[i];
b[i] = sum;
}
ll res = INT_MAX;
rep(i,N-1){
res = min(res,abs(sum-2*b[i]));
}
cout<<res<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:14:9: error: 'sum' was not declared in this scope
14 | sum += a[i];
| ^~~
a.cc:20:27: error: 'sum' was not declared in this scope
20 | res = min(res,abs(sum-2*b[i]));
| ^~~
|
s850463780 | p03659 | Java | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author zhangyong
*/
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
Scanner in = new Scanner(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, Scanner in, PrintWriter out) {
int n;
n = in.nextInt();
int[] arr = new int[n];
long sum = 0;
for (int i = 0; i < arr.length; i++) {
arr[i] = in.nextInt();
sum += arr[i];
}
Arrays.sort(arr);
long x = 0, min = 1000000000000000000;
for (int i = 0; i < n; i++) {
x += arr[i];
if (i + 1 < n) min = Math.min(min, Math.abs(sum - 2 * x));
}
out.println(min);
}
}
}
| Main.java:36: error: integer number too large
long x = 0, min = 1000000000000000000;
^
1 error
|
s542366818 | p03659 | Java | #include <iostream>
#include <vector>
#include <numeric>
#include <climits>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> v;
for (int i=0; i<n; ++i) {
int a;
cin >> a;
v.push_back(a);
}
unsigned long long snuke_ = accumulate(v.begin(), v.end(), 0);
unsigned long long raccoon = 0;
unsigned long long res = ULLONG_MAX;
for (int i=n-1; i>0; --i) {
int a = v[i];
snuke_ -= a;
raccoon += a;
res = min(res, abs(snuke_-raccoon));
}
cout << res << endl;
} | Main.java:1: error: illegal character: '#'
#include <iostream>
^
Main.java:2: error: illegal character: '#'
#include <vector>
^
Main.java:3: error: illegal character: '#'
#include <numeric>
^
Main.java:4: error: illegal character: '#'
#include <climits>
^
Main.java:9: error: not a statement
cin >> n;
^
Main.java:13: error: not a statement
cin >> a;
^
Main.java:16: error: not a statement
unsigned long long snuke_ = accumulate(v.begin(), v.end(), 0);
^
Main.java:16: error: not a statement
unsigned long long snuke_ = accumulate(v.begin(), v.end(), 0);
^
Main.java:17: error: not a statement
unsigned long long raccoon = 0;
^
Main.java:17: error: not a statement
unsigned long long raccoon = 0;
^
Main.java:18: error: not a statement
unsigned long long res = ULLONG_MAX;
^
Main.java:18: error: not a statement
unsigned long long res = ULLONG_MAX;
^
Main.java:25: error: not a statement
cout << res << endl;
^
Main.java:7: error: unnamed classes are a preview feature and are disabled by default.
int main() {
^
(use --enable-preview to enable unnamed classes)
Main.java:16: error: ';' expected
unsigned long long snuke_ = accumulate(v.begin(), v.end(), 0);
^
Main.java:16: error: ';' expected
unsigned long long snuke_ = accumulate(v.begin(), v.end(), 0);
^
Main.java:17: error: ';' expected
unsigned long long raccoon = 0;
^
Main.java:17: error: ';' expected
unsigned long long raccoon = 0;
^
Main.java:18: error: ';' expected
unsigned long long res = ULLONG_MAX;
^
Main.java:18: error: ';' expected
unsigned long long res = ULLONG_MAX;
^
20 errors
|
s116822290 | p03659 | Java | #include <iostream>
#include <vector>
#include <numeric>
#include <climits>
using namespace std;
int main() {
int n;
cin >> n;
vector<int> v;
for (int i=0; i<n; ++i) {
int a;
cin >> a;
v.push_back(a);
}
long long snuke_ = accumulate(v.begin(), v.end(), 0);
long long raccoon = 0;
long long res = ULLONG_MAX;
for (int i=n-1; i>0; --i) {
int a = v[i];
snuke_ -= a;
raccoon += a;
res = min(res, abs(snuke_-raccoon));
}
cout << res << endl;
} | Main.java:1: error: illegal character: '#'
#include <iostream>
^
Main.java:2: error: illegal character: '#'
#include <vector>
^
Main.java:3: error: illegal character: '#'
#include <numeric>
^
Main.java:4: error: illegal character: '#'
#include <climits>
^
Main.java:9: error: not a statement
cin >> n;
^
Main.java:13: error: not a statement
cin >> a;
^
Main.java:16: error: not a statement
long long snuke_ = accumulate(v.begin(), v.end(), 0);
^
Main.java:17: error: not a statement
long long raccoon = 0;
^
Main.java:18: error: not a statement
long long res = ULLONG_MAX;
^
Main.java:25: error: not a statement
cout << res << endl;
^
Main.java:7: error: unnamed classes are a preview feature and are disabled by default.
int main() {
^
(use --enable-preview to enable unnamed classes)
Main.java:16: error: ';' expected
long long snuke_ = accumulate(v.begin(), v.end(), 0);
^
Main.java:17: error: ';' expected
long long raccoon = 0;
^
Main.java:18: error: ';' expected
long long res = ULLONG_MAX;
^
14 errors
|
s337540652 | p03659 | C++ | #include <cstdio>
#include <algorithm>
#define ll long long
#define MAXN 200000
#define MAXL 1000000000
ll f[MAXN + 1];
int main() {
ll n, total = 0, sum = 0, rez = LONG_LONG_MAX, dif;
scanf("%lld", &n);
for (int i = 1; i <= n; i++) {
scanf("%lld", &f[i]);
total += f[i];
}
for (int i = 1; i <= n; i++) {
sum += f[i];
if (total - 2 * sum > 0)
dif = total - 2 * sum;
else
dif = 2 * sum - total;
if (i < n)
rez = std::min(rez, dif);
}
printf("%lld", rez);
return 0;
}
| a.cc: In function 'int main()':
a.cc:13:37: error: 'LONG_LONG_MAX' was not declared in this scope
13 | ll n, total = 0, sum = 0, rez = LONG_LONG_MAX, dif;
| ^~~~~~~~~~~~~
a.cc:22:13: error: 'dif' was not declared in this scope; did you mean 'div'?
22 | dif = total - 2 * sum;
| ^~~
| div
a.cc:24:13: error: 'dif' was not declared in this scope; did you mean 'div'?
24 | dif = 2 * sum - total;
| ^~~
| div
a.cc:26:33: error: 'dif' was not declared in this scope; did you mean 'div'?
26 | rez = std::min(rez, dif);
| ^~~
| div
|
s364588768 | p03659 | Java | import java.io.*;
class Main{
public static void main(String arg[]) throws IOException{
String message;
int n=0;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
message = br.readLine();
String num[] = message.split(" ");
message = br.readLine();
String nagasa[] = message.split(" ");
n = Integer.parseInt(num[0]);
int numnum[] = new int[n];
long int all = 0;
int harf = 0;
for(int i=0;i<n;i++){
numnum[i] = Integer.parseInt(nagasa[i]);
all += numnum[i];
}
long int akun = 0;
long int bkun = 0;
long int maxlong=9999999;
for(int i=1;i<n+1;i++){
for(int j=1;j<i+1;j++){
akun += numnum[j-1];
}
if(maxlong>Math.abs(all-akun)){
maxlong = Math.abs(all - (akun));
}
akun = 0;
}
System.out.println(""+maxlong);
}
}
| Main.java:15: error: not a statement
long int all = 0;
^
Main.java:15: error: ';' expected
long int all = 0;
^
Main.java:21: error: not a statement
long int akun = 0;
^
Main.java:21: error: ';' expected
long int akun = 0;
^
Main.java:22: error: not a statement
long int bkun = 0;
^
Main.java:22: error: ';' expected
long int bkun = 0;
^
Main.java:23: error: not a statement
long int maxlong=9999999;
^
Main.java:23: error: ';' expected
long int maxlong=9999999;
^
8 errors
|
s244392666 | p03659 | C++ | #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#define N 200000+10
using namespace std;
int a[N];
int b[N];
int n;
int main()
{
cin>>n;
b[0]=0;
long long ans=1e18;
for(int i=1;i<=n;i++)
{
cin>>a[i];
b[i]+=b[i-1]+a[i];
}
for(int i=1;i<=n-1;i++)
{
int sum2=b[n]-b[i];
ans=min(ans,abs(b[i]-sum2));
}
cout<<ans<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:24:24: error: no matching function for call to 'min(long long int&, int)'
24 | ans=min(ans,abs(b[i]-sum2));
| ~~~^~~~~~~~~~~~~~~~~~~~
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:24:24: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
24 | ans=min(ans,abs(b[i]-sum2));
| ~~~^~~~~~~~~~~~~~~~~~~~
/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:3:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:24:24: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
24 | ans=min(ans,abs(b[i]-sum2));
| ~~~^~~~~~~~~~~~~~~~~~~~
|
s803419732 | p03659 | Java | import java.io.*;
class Main{
public static void main(String arg[]) throws IOException{
String message;
int n=0;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
message = br.readLine();
String num[] = message.split(" ");
message = br.readLine();
String nagasa[] = message.split(" ");
n = Integer.parseInt(num[0]);
int numnum[] = new int[n];
long long int all = 0;
int harf = 0;
for(int i=0;i<n;i++){
numnum[i] = Integer.parseInt(nagasa[i]);
all += numnum[i];
}
long long int akun = 0;
long long int bkun = 0;
long long int maxlong=9999999;
for(int i=1;i<n+1;i++){
for(int j=1;j<i+1;j++){
akun += numnum[j-1];
}
if(maxlong>Math.abs(all-akun)){
maxlong = Math.abs(all - (akun));
}
akun = 0;
}
System.out.println(""+maxlong);
}
} | Main.java:15: error: not a statement
long long int all = 0;
^
Main.java:15: error: ';' expected
long long int all = 0;
^
Main.java:15: error: not a statement
long long int all = 0;
^
Main.java:15: error: ';' expected
long long int all = 0;
^
Main.java:21: error: not a statement
long long int akun = 0;
^
Main.java:21: error: ';' expected
long long int akun = 0;
^
Main.java:21: error: not a statement
long long int akun = 0;
^
Main.java:21: error: ';' expected
long long int akun = 0;
^
Main.java:22: error: not a statement
long long int bkun = 0;
^
Main.java:22: error: ';' expected
long long int bkun = 0;
^
Main.java:22: error: not a statement
long long int bkun = 0;
^
Main.java:22: error: ';' expected
long long int bkun = 0;
^
Main.java:23: error: not a statement
long long int maxlong=9999999;
^
Main.java:23: error: ';' expected
long long int maxlong=9999999;
^
Main.java:23: error: not a statement
long long int maxlong=9999999;
^
Main.java:23: error: ';' expected
long long int maxlong=9999999;
^
16 errors
|
s996080689 | p03659 | C++ | #include "bits/stdc++.h"
using namespace std;
int main() {
int N;
cin >> N;
long long a[N];
for (int i = 0; i < N; i++) {
cin >> a[i];
}
long long x = a[0];
long long y = 0;
for(int i = 1; i < N; i++) {
y += a[i];
}
long long min = abs(x-y);
for (int i = 1; i < N-1; i++) {
x += a[i];
y -= a[i];
long long = abs(x-y);
if(dif < min) min = dif;
}
cout << min << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:22:15: error: expected unqualified-id before '=' token
22 | long long = abs(x-y);
| ^
a.cc:23:8: error: 'dif' was not declared in this scope; did you mean 'div'?
23 | if(dif < min) min = dif;
| ^~~
| div
|
s995103393 | p03659 | C++ | #define rep(i, s, e) for(int i=(s); i<e; i++)
#include <deque>
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;
int a, n;
deque<int> q;
int nearN(long long arai, long long snuke, long long sum, long long sikii){
while(!q.empty() && abs(sikii - (snuke+q.front())) <= abs(sikii - snuke)){
snuke+=q.front();
q.pop_front();
}
arai=sum-snuke;
return abs(arai-snuke);
}
long long main() {
cin >> n;
rep(i, 0, n-1){
cin >> a; q.push_back(a);
}
long long snuke = q.front(); q.pop_front();
long long arai; cin >> arai;
long long sum=arai+snuke; for(auto x: q) sum+=x;
cout << nearN(arai, snuke, sum, sum/2 + 0.5) << endl;
} | cc1plus: error: '::main' must return 'int'
|
s632536462 | p03659 | C | #include <stdio.h>
int abs(int num)
{
if(num < 0)
return -num;
else
return num;
}
int main(void)
{
int n;
long long a[200000];
long long all, sunuke, min;
int i;
scanf("%d", &n);
all = 0;
for(i=0; i<n; i++){
scanf("%lld", &a[i]);
all += a[i];
}
sunuke = a[0];
min = abs(2*sunuke-all);
for(i=1; i<n-1; i++){
sunuke += a[i];
if( abs(2*sunuke-arai) < min )
min = abs(2*sunuke-arai);
}
printf("%lld\n", min);
return 0;
} | main.c: In function 'main':
main.c:30:34: error: 'arai' undeclared (first use in this function)
30 | if( abs(2*sunuke-arai) < min )
| ^~~~
main.c:30:34: note: each undeclared identifier is reported only once for each function it appears in
|
s080452782 | p03659 | C++ | #include <iostream>
using namespace std;
int main(void)
{
int i;
int n;
long long sum,
long long temp;
long long ans;
long long kotae;
cin >> n;
long long a[n];
for(i = 0; i < n; i++){
cin >> a[i];
}
sum = 0;
for(i = 0; i < n; i++){
sum = sum +a[i];
}
kotae = 2*a[0] - sum;
if(kotae < 0){
kotae = kotae * -1;
}
temp = a[0];
for(i = 1; i < n-1; i++){
ans = 0;
temp = temp + a[i];
ans = 2*temp - sum;
//絶対値処理
if(ans < 0){
ans = ans * -1;
}
if(ans < kotae){
kotae = ans;
}
if(kotae == 0){
break;
}
}
cout << kotae << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:9:5: error: expected unqualified-id before 'long'
9 | long long temp;
| ^~~~
a.cc:28:5: error: 'temp' was not declared in this scope; did you mean 'tm'?
28 | temp = a[0];
| ^~~~
| tm
|
s933054239 | p03659 | C++ | #include <iostream>
#include <vector>
#define int long long int
#define ab(a,b) (a>b)?((a)-(b)):((b)-(a))
using namespace std;
unsigned main() {
int n;
int buf;
int sum = 0;
vector<int> a;
cin >> n;
int s;
cin >> buf;
sum += buf;
a.push_back(buf);
for (int i = 1; i<n; i++) {
cin >> buf;
sum += buf;
a.push_back(buf);
}
int min = 9223372036854775807;
s=0;
for (int i = 0; i<n-1; i++) {
s+=a[i];
if (ab(sum - s, s)<min)min = ab(sum - s, s);
}
cout << min << endl;
return 0;
}
| cc1plus: error: '::main' must return 'int'
|
s283486109 | p03659 | C++ | #include <iostream>
#include <vector>
#define int long long int
#define ab(a,b) (a>b)?((a)-(b)):((b)-(a))
using namespace std;
int main() {
int n;
int buf;
int sum = 0;
vector<int> a;
cin >> n;
int s;
cin >> buf;
sum += buf;
a.push_back(buf);
for (int i = 1; i<n; i++) {
cin >> buf;
sum += buf;
a.push_back(buf);
}
int min = 9223372036854775807;
s=0;
for (int i = 0; i<n-1; i++) {
s+=a[i];
if (ab(sum - s, s)<min)min = ab(sum - s, s);
}
cout << min << endl;
return 0;
}
| a.cc:3:23: error: '::main' must return 'int'
3 | #define int long long int
| ^~~
a.cc:6:1: note: in expansion of macro 'int'
6 | int main() {
| ^~~
|
s620475064 | p03659 | C | #include <stdio.h>
#include <stdlib.h>
int compare_int(const void *a, const void *b)
{
return *(int*)a - *(int*)b;
}
int main(int argc, char **argv){
int n;
int sum = 0;
scanf("%d\n", &n);
int card[n];
int sumArray[n];
for (int i = 0; i < n; i++) {
scanf("%d", &card[i]);
}
for (int i = 0; i < n; i++) {
sum += card[i];
sumArray[i] = sum;
}
for (int i = 0; i < n; i++) {
sumArray[i] = abs(sum - sumArray[i] * 2n);
}
qsort(sumArray, n, sizeof(int), compare_int);
printf("%d\n", sumArray[0]);
}
| main.c: In function 'main':
main.c:23:55: error: invalid suffix "n" on integer constant
23 | sumArray[i] = abs(sum - sumArray[i] * 2n);
| ^~
|
s543596447 | p03659 | C++ | /// Md.ASADUZZAMAN
/// Dept of ICT
/// MBSTU
#include<bits/stdc++.h>
using namespace std;
#define fr(i,a,b) for(int i=(a);i<(b);i++)
#define rfr(i,a,b) for(int i=(b-1);i>=(a);i--)
#define freach(i, c) for( __typeof( (c).begin() ) i = (c).begin(); i != (c).end(); ++i )
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define PINF INT_MAX
#define MINF INT_MIN
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mset(a,c) memset(a,c,sizeof a)
#define clr(a) memset(a,0,sizeof a)
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define psi pair<sting,int>
#define pis pair<int,string>
#define ff first
#define ss second
#define vs vector<string>
#define vi vector<int>
#define vll vector<long long>
#define vpi vector<pair<int,int> >
#define vpl vector<pair<long long,long long> >
#define qi queue<int>
#define ql queue<long>
#define qll queue<long long>
#define PQ priority_queue
#define mpii map<int,int>
#define mpsi map<string,int>
#define mpci map<char,int>
#define mpll map<long long,long long>
#define bug(x) cout<<#x<<": "<<x<<endl
#define bug1(x,y) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define bug2(x,y,z) cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl
#define min(a,b) (a>b?b:a)
#define max(a,b) (a>b?a:b)
#define pi acos(-1.0)
#define rad(x) (((1.0 * x * pi) / 180.0))
#define deg(x) (((x * 180.0) / (1.0 * pi)))
#define sinr(x) (sin(rad(x)))
#define cosr(x) (cos(rad(x)))
#define tanr(x) (tan(rad(x)))
#define asind(x) (deg((asin(x))))
#define acosd(x) (deg((acos(x))))
#define atand(x) (deg((atan(x))))
#define setbiton(x, i) (x |= (1 << i))
#define setbitoff(x, i) (x ^= (1 << i))
#define countbit(x) __builtin_popcountll((ll)x)
#define resetbit(x, i) (x &= (~(1 << i)))
#define LB(a,x) (lower_bound(all(a),x)-a.begin()) // first element in the range [first,last) which does not compare less than val.
#define UB(a,x) (upper_bound(all(a),x)-a.begin()) // first element in the range [first,last) which compares greater than val.
#define Unique(store) store.resize(unique(store.begin(),store.end())-store.begin())
#define mxe(a,n) (*max_element(a,a+n))
#define mxv(v) (*max_element(v.begin(), v.end()))
#define mne(a,n) (*min_element(a,a+n))
#define mnv(v) (*min_element(v.begin(), v.end()))
#define SUM(a,n) (accumulate(a,a+n,0))
#define SUMv(v) (accumulate(v.begin(), v.end(), 0))
#define occurx(v,x) (count(v.begin(), v.end(),x))
#define findx(v,x) (find(v.begin(), v.end(),x))
#define swap(a,b) a^=b^=a^=b
#define bin_sa(a,n,x) (binary_search(a, a+n,x))
#define bin_sv(v,x) (binary_search(v.begin(), v.end(),x))
#define sgn(x,y) ((x)+eps<(y)?-1:((x)>eps+(y)?1:0))
#define input() freopen("in0.txt","r",stdin)
#define output()freopen("out0.txt","w",stdout)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);
#define IN scanf
#define OUT printf
/// #define SI(a) scanf("%d",&a)
/// #define SL(a) scanf("%lld",&a)
/// #define SD(a) scanf("%lf",&a)
/// #define OI(a) printf("%d",a)
/// #define OL(a) printf("%lld",a)
/// #define OD(a) printf("%lf",a)
/// #define ON() printf("\n")
#define ll long long
#define ull unsigned long long
#define EPS 1e-9
#define inf 1e18
#define MOD 1000000007
int main()
{
#ifndef ONLINE_JUDGE
//input();
//output();
#endif
fast();
// clock_t begin, end;
// double time_spent;
// begin = clock();
ll n,x,y,a,b,c,t,q;
string s;
//char c;
//cin>>t;
while(cin>>n)
{
vll v;
ll sm=0;
fr(i,0,n)
cin>>x,v.pb(x),sm+=x;
x=0;
ll mn=1e18;
vector<double> v1;
fr(i,0,n)
{
x+=v[i];
if(x)
v1.pb(sm-2*x));//bug(x);
}
if(v1.size())
sort(all(v1));
if(v1.size())
cout<<(ll)v1[0]<<endl;
else cout<<"0"<<endl;
}
// end = clock();
// time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
// cout<<"Time spent = "<<time_spent<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:142:26: error: expected ';' before ')' token
142 | v1.pb(sm-2*x));//bug(x);
| ^
| ;
|
s428166141 | p03659 | C++ | #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
__int64 sum(int num[],int first,int last)
{
int i;
__int64 k=0;
for (i=first;i<=last;i++)
{
k+=num[i];
}
return k;
}
__int64 digui(int first,int last,int num[],int most)
{
int middle;
if (first>=last)
return abs(sum(num,0,first)-sum(num,first+1,most));
else
{
middle=(first+last)/2;
if (sum(num,0,middle)>sum(num,middle+1,most))
return digui(first,middle-1,num,most);
else if (sum(num,0,middle)<sum(num,middle+1,most))
return digui(middle+1,last,num,most);
else
return 0;
}
}
int main()
{
int num[200010]={};
int n,i;
__int64 cha;
while (scanf("%d",&n)!=EOF)
{
for (i=0;i<n;i++)
{
scanf("%d",&num[i]);
}
cha=digui(0,n-1,num,n-1);
printf ("%I64d\n",cha);
}
return 0;
} | a.cc:9:1: error: '__int64' does not name a type; did you mean '__int64_t'?
9 | __int64 sum(int num[],int first,int last)
| ^~~~~~~
| __int64_t
a.cc:20:1: error: '__int64' does not name a type; did you mean '__int64_t'?
20 | __int64 digui(int first,int last,int num[],int most)
| ^~~~~~~
| __int64_t
a.cc: In function 'int main()':
a.cc:41:5: error: '__int64' was not declared in this scope; did you mean '__ynf64'?
41 | __int64 cha;
| ^~~~~~~
| __ynf64
a.cc:48:9: error: 'cha' was not declared in this scope; did you mean 'char'?
48 | cha=digui(0,n-1,num,n-1);
| ^~~
| char
a.cc:48:13: error: 'digui' was not declared in this scope
48 | cha=digui(0,n-1,num,n-1);
| ^~~~~
|
s232312358 | p03659 | C++ | include<cstdio>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
const long long maxn=1e7+10;
long long a[maxn];
int main()
{
long long N;
long long i;
cin>>N;
long long sum=0;
for(i=0;i<N;i++){
cin>>a[i];
sum+=a[i];
}
long long k;
k=fabs(sum-2*a[0]);
for(i=0;i<N-1;i++)
{
sum-=2*a[i];
if(k>fabs(sum))
k=fabs(sum);
}
if(k<0)
k*=-1;
printf("%lld",k);
return 0;
} | a.cc:1:1: error: 'include' does not name a type
1 | include<cstdio>
| ^~~~~~~
In file included from /usr/include/c++/14/iosfwd:42,
from /usr/include/c++/14/ios:40,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/bits/postypes.h:68:11: error: 'ptrdiff_t' does not name a type
68 | typedef ptrdiff_t streamsize; // Signed integral type
| ^~~~~~~~~
/usr/include/c++/14/bits/postypes.h:41:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
40 | #include <cwchar> // For mbstate_t
+++ |+#include <cstddef>
41 |
In file included from /usr/include/c++/14/bits/exception_ptr.h:38,
from /usr/include/c++/14/exception:166,
from /usr/include/c++/14/ios:41:
/usr/include/c++/14/new:131:26: error: declaration of 'operator new' as non-function
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:131:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
131 | _GLIBCXX_NODISCARD void* operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
In file included from /usr/include/wchar.h:35,
from /usr/include/c++/14/cwchar:44,
from /usr/include/c++/14/bits/postypes.h:40:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:132:41: error: attributes after parenthesized initializer ignored [-fpermissive]
132 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:133:26: error: declaration of 'operator new []' as non-function
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~~~
/usr/include/c++/14/new:133:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
133 | _GLIBCXX_NODISCARD void* operator new[](std::size_t) _GLIBCXX_THROW (std::bad_alloc)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:134:41: error: attributes after parenthesized initializer ignored [-fpermissive]
134 | __attribute__((__externally_visible__));
| ^
/usr/include/c++/14/new:140:29: error: 'std::size_t' has not been declared
140 | void operator delete(void*, std::size_t) _GLIBCXX_USE_NOEXCEPT
| ^~~
/usr/include/c++/14/new:142:31: error: 'std::size_t' has not been declared
142 | void operator delete[](void*, std::size_t) _GLIBCXX_USE_NOEXCEPT
| ^~~
/usr/include/c++/14/new:145:26: error: declaration of 'operator new' as non-function
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/new:145:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:145:52: error: expected primary-expression before 'const'
145 | _GLIBCXX_NODISCARD void* operator new(std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~
/usr/include/c++/14/new:147:26: error: declaration of 'operator new []' as non-function
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/new:147:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:147:54: error: expected primary-expression before 'const'
147 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, const std::nothrow_t&) _GLIBCXX_USE_NOEXCEPT
| ^~~~~
/usr/include/c++/14/new:154:26: error: declaration of 'operator new' as non-function
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^~~~~~~~
/usr/include/c++/14/new:154:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:154:68: error: expected primary-expression before ')' token
154 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t)
| ^
/usr/include/c++/14/new:155:73: error: attributes after parenthesized initializer ignored [-fpermissive]
155 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__));
| ^
/usr/include/c++/14/new:156:26: error: declaration of 'operator new' as non-function
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~~~
/usr/include/c++/14/new:156:44: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:156:68: error: expected primary-expression before ',' token
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^
/usr/include/c++/14/new:156:70: error: expected primary-expression before 'const'
156 | _GLIBCXX_NODISCARD void* operator new(std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~
/usr/include/c++/14/new:162:26: error: declaration of 'operator new []' as non-function
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^~~~~~~~
/usr/include/c++/14/new:162:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:162:70: error: expected primary-expression before ')' token
162 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t)
| ^
/usr/include/c++/14/new:163:73: error: attributes after parenthesized initializer ignored [-fpermissive]
163 | __attribute__((__externally_visible__, __alloc_size__ (1), __malloc__));
| ^
/usr/include/c++/14/new:164:26: error: declaration of 'operator new []' as non-function
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~~~
/usr/include/c++/14/new:164:46: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
214 | typedef __SIZE_TYPE__ size_t;
| ^~~~~~
/usr/include/c++/14/new:164:70: error: expected primary-expression before ',' token
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^
/usr/include/c++/14/new:164:72: error: expected primary-expression before 'const'
164 | _GLIBCXX_NODISCARD void* operator new[](std::size_t, std::align_val_t, const std::nothrow_t&)
| ^~~~~
/usr/include/c++/14/new:171:29: error: 'std::size_t' has not been declared
171 | void operator delete(void*, std::size_t, std::align_val_t)
| ^~~
/usr/include/c++/14/new:173:31: error: 'std::size_t' has not been declared
173 | void operator delete[](void*, std::size_t, std::align_val_t)
| ^~~
/usr/include/c++/14/new:179:33: error: declaration of 'operator new' as non-function
179 | _GLIBCXX_NODISCARD inline void* operator new(std::size_t, void* __p) _GLIBCXX_USE_NOEXCEPT
| ^~~~~~~~
/usr/include/c++/14/new:179:51: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
179 | _GLIBCXX_NO |
s383431271 | p03659 | C++ | #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
__int64 sum(int num[],int first,int last)
{
int i;
__int64 k=0;
for (i=first;i<=last;i++)
{
k+=num[i];
}
return k;
}
__int64 digui(int first,int last,int num[],int most)
{
int middle;
if (first>=last)
return abs(sum(num,0,first)-sum(num,first+1,most));
else
{
middle=(first+last)/2;
if (sum(num,0,middle)>sum(num,middle+1,most))
return digui(first,middle-1,num,most);
else if (sum(num,0,middle)<sum(num,middle+1,most))
return digui(middle+1,last,num,most);
else
return 0;
}
}
int main()
{
int num[200010]={};
int n,i;
__int64 cha;
while (scanf("%d",&n)!=EOF)
{
for (i=0;i<n;i++)
{
scanf("%d",&num[i]);
}
cha=digui(0,n-1,num,n-1);
printf ("%I64d\n",cha);
}
return 0;
} | a.cc:9:1: error: '__int64' does not name a type; did you mean '__int64_t'?
9 | __int64 sum(int num[],int first,int last)
| ^~~~~~~
| __int64_t
a.cc:20:1: error: '__int64' does not name a type; did you mean '__int64_t'?
20 | __int64 digui(int first,int last,int num[],int most)
| ^~~~~~~
| __int64_t
a.cc: In function 'int main()':
a.cc:41:5: error: '__int64' was not declared in this scope; did you mean '__ynf64'?
41 | __int64 cha;
| ^~~~~~~
| __ynf64
a.cc:48:9: error: 'cha' was not declared in this scope; did you mean 'char'?
48 | cha=digui(0,n-1,num,n-1);
| ^~~
| char
a.cc:48:13: error: 'digui' was not declared in this scope
48 | cha=digui(0,n-1,num,n-1);
| ^~~~~
|
s810469411 | p03659 | C++ | #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<numeric>
using namespace std;
typedef long long LL;
vector<LL>a;
vector<LL>b;
LL y=0;
int main(){
int n;
cin>>n;
LL x;
for(int i=0;i<n;i++){
cin>>x;
a.push_back(x);
}
for(int i=0;i<n-1;i++)
b.push_back(abs(accumulate(a.begin(),a.at(i),y)-accumulate(a.at(i+1),a.end(),y)));
sort(b.begin(),b.end());
cout<<b[0];
return 0;
} | a.cc: In function 'int main()':
a.cc:21:35: error: no matching function for call to 'accumulate(std::vector<long long int>::iterator, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&, LL&)'
21 | b.push_back(abs(accumulate(a.begin(),a.at(i),y)-accumulate(a.at(i+1),a.end(),y)));
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/numeric:62,
from a.cc:6:
/usr/include/c++/14/bits/stl_numeric.h:134:5: note: candidate: 'template<class _InputIterator, class _Tp> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp)'
134 | accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
| ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:134:5: note: template argument deduction/substitution failed:
a.cc:21:35: note: deduced conflicting types for parameter '_InputIterator' ('__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' and 'long long int')
21 | b.push_back(abs(accumulate(a.begin(),a.at(i),y)-accumulate(a.at(i+1),a.end(),y)));
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:161:5: note: candidate: 'template<class _InputIterator, class _Tp, class _BinaryOperation> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp, _BinaryOperation)'
161 | accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
| ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:161:5: note: candidate expects 4 arguments, 3 provided
a.cc:21:67: error: no matching function for call to 'accumulate(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&, std::vector<long long int>::iterator, LL&)'
21 | b.push_back(abs(accumulate(a.begin(),a.at(i),y)-accumulate(a.at(i+1),a.end(),y)));
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:134:5: note: candidate: 'template<class _InputIterator, class _Tp> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp)'
134 | accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
| ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:134:5: note: template argument deduction/substitution failed:
a.cc:21:67: note: deduced conflicting types for parameter '_InputIterator' ('long long int' and '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >')
21 | b.push_back(abs(accumulate(a.begin(),a.at(i),y)-accumulate(a.at(i+1),a.end(),y)));
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:161:5: note: candidate: 'template<class _InputIterator, class _Tp, class _BinaryOperation> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp, _BinaryOperation)'
161 | accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
| ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:161:5: note: candidate expects 4 arguments, 3 provided
|
s835657332 | p03659 | C++ | #include <cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
#include <numeric>
#include <cmath>
using namespace std;
int main(){
int n;
vector<int> v;
scanf("%d",&n);
for (int i = 0; i < n; i++){
int x;
scanf("%d",&x);
v.push_back(x);
}
long long r = 10000000;
for (int i = 1; i < n; i++){
int sunuke = 0;
int arai = 0;
for (int j = 0; j < i; j++){
sunuke += v[j];
}
for (int k = i; k < n; k++){
arai += v[k];
}
int sa = abs(sunuke-arai);
if (r > sa){
r = sa;
}
}
printf("%d",r[0]);
} | a.cc: In function 'int main()':
a.cc:34:18: error: invalid types 'long long int[int]' for array subscript
34 | printf("%d",r[0]);
| ^
|
s772198541 | p03659 | C++ | #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#define N 200000+10
using namespace std;
int a[N];
int f[N];
int v[N];
int w[N];
int n;
int solove(int SUM)
{
for(i=0;i<n;i++)
{
for(j=1;j<SUM/2;j++)
{
}
}
}
int main()
{
cin>>n;
for(int i=0;i<n;i++) cin>>a[i];
sort(a,a+n);
for(int i=0;i<n;i++) sum+=a[i];
int x=0,y=0;
for(int i=0;i<n-1;i++)
{
x+=a[i];
for(int j=i+1;j<n;j++)
{
}
}
} | a.cc: In function 'int solove(int)':
a.cc:14:13: error: 'i' was not declared in this scope
14 | for(i=0;i<n;i++)
| ^
a.cc:16:21: error: 'j' was not declared in this scope
16 | for(j=1;j<SUM/2;j++)
| ^
a.cc:23:1: warning: no return statement in function returning non-void [-Wreturn-type]
23 | }
| ^
a.cc: In function 'int main()':
a.cc:29:30: error: 'sum' was not declared in this scope
29 | for(int i=0;i<n;i++) sum+=a[i];
| ^~~
|
s622002272 | p03659 | C++ | #include <iostream>
using namespace std;
int main()
{
int N, x(0), y(0), min(32767);
bool imput(false);
cin >> N;
if((N>=2) && ( N<=2*pow(10,5) )) imput = true;
if(imput)
{
int *a = new int [N];
for(int i(0); i < N; i++)
cin >> a[i];
for(int i(1); i <= N-1; i++)
{
for(int i(0); i < N; i++) y += a[i];
for(int j(0); j < i; j++)
{
x += a[j];
}
y -= x;
if(abs(x-y) < min) min = abs(x-y);
x=0; y=0;
}
delete a;
}
cout << min <<endl;
system("pause");
return(0);
} | a.cc: In function 'int main()':
a.cc:10:29: error: 'pow' was not declared in this scope
10 | if((N>=2) && ( N<=2*pow(10,5) )) imput = true;
| ^~~
|
s668867100 | p03659 | C++ | #include <iostream>
using namespace std;
int main()
{
int N, x(0), y(0), min(32767);
bool imput(false);
cin >> N;
if((N>=2) && ( N<=2*pow(10,5) )) imput = true;
if(imput)
{
int *a = new int [N];
for(int i(0); i < N; i++)
cin >> a[i];
for(int i(1); i <= N-1; i++)
{
for(int i(0); i < N; i++) y += a[i];
for(int j(0); j < i; j++)
{
x += a[j];
}
y -= x;
if(abs(x-y) < min) min = abs(x-y);
x=0; y=0;
}
delete a;
}
cout << min <<endl;
system("pause");
return(0);
} | a.cc: In function 'int main()':
a.cc:10:29: error: 'pow' was not declared in this scope
10 | if((N>=2) && ( N<=2*pow(10,5) )) imput = true;
| ^~~
|
s629103269 | p03659 | C++ | #include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdlib>
#include <cmath>
using namespace std;
int main(){
int n;
int a;
cin>>n;
int num;
vector<int> v;
for(int i=0; i<n; i++){
cin>>a;
num+=a;
v.push_back(a);
}
int left=0;
int right=num;
int mini=999999999999;
for(int i=0;i<n-1; i++){
left+=v[i];
right-=v[i];
int key=abs(left-right);
mini=min(min,key);
}
cout<<mini<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:22:15: warning: overflow in conversion from 'long int' to 'int' changes value from '999999999999' to '-727379969' [-Woverflow]
22 | int mini=999999999999;
| ^~~~~~~~~~~~
a.cc:27:17: error: no matching function for call to 'min(<unresolved overloaded function type>, int&)'
27 | mini=min(min,key);
| ~~~^~~~~~~~~
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: 'constexpr const _Tp& std::min(const _Tp&, const _Tp&) [with _Tp = int]'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:20: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const int&'
233 | min(const _Tp& __a, const _Tp& __b)
| ~~~~~~~~~~~^~~
/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:3:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:27:17: note: couldn't deduce template parameter '_Tp'
27 | mini=min(min,key);
| ~~~^~~~~~~~~
|
s636140377 | p03659 | C++ | #include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
const long long maxn=20000+10;
long long a[maxn];
int main()
{
long long N;
long long i;
cin>>N;
long long sum=0;
for(i=0;i<N;i++){
scanf("%lld",&a[i]);
sum+=a[i];
}
long long k;
k=fabs(sum-2*a[0]);
for(i=0;i<N-1;i++)
{
sum-=2*a[i];
if(k>fabs(sum))
k=fabs(sum);
}
if(k<0)
k*=-1;
printf("%lld",k);
return 0;
} | a.cc: In function 'int main()':
a.cc:12:9: error: 'cin' was not declared in this scope
12 | cin>>N;
| ^~~
a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
4 | #include<algorithm>
+++ |+#include <iostream>
5 | using namespace std;
|
s072981838 | p03659 | C++ | #include <stdio.h>
int main()
{
long a, i, x;
long sum = 0;
long sumn = 0;
long min = 2000000001;
long c[200000];
scanf("%ld", &a);
for (i = 0; i < a; i++) {
scanf("%ld", &c[i]);
sum += c[i];
}
for (i = 0; i < a-1; i++) {
sumn += c[i];
if (sum - sumn*2 > 0) {
x = sum - sumn*2;
}
else {
x = sumn*2 - sum;
}
if (x < min) {
min = x;
}
}
printf("%ld", min);
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 |
| ^
|
s037115745 | p03659 | C++ | include <cstdio>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <list>
#include <algorithm>
using namespace std;
typedef long long LL;
typedef double DB;
typedef unsigned long long ULL;
typedef unsigned int Uint;
const int INT_INF=0x3fffffff;
const LL LL_INF=0x3fffffffffffffff;
const DB EPS=1e-9;
const DB PI=3.14159265358979323846;
const int N=100010;
const int E=100010;
#define PB push_back
#define MP make_pair
#define MH make_heap
#define PH push
LL a[N];
LL s[N];
LL ans[N];
bool cmp(LL a,LL b)
{
return a>b;
}
int main()
{
LL n , m;
while(~scanf("%I64d",&n))
{
for(int i=1; i<=n; i++)
scanf("%I64d",a+i);
sort(a+1,a+1+n,cmp);
memset(s,0,sizeof(s));
for(int i=1; i<=n; i++)
s[i]=s[i-1]+a[i];
memset(ans,-1,sizeof(ans));
scanf("%I64d",&m);
for(int ca=0, val; ca<m; ca++)
{
scanf("%d",&val);
if(val>n) val=n;
if(ans[val]==-1)
{
ans[val]=0;
for(LL L=1, R=L+val, step=val, deep=1; L<n; L=R, deep++, step*=val)
{
R=L+step;
if(R>n) R=n;
ans[val]+=deep*(s[R]-s[L]);
}
}
printf("%I64d",ans[val]);
if(ca==m-1) printf("\n");
else printf(" ");
}
}
return 0;
} | a.cc:1:1: error: 'include' does not name a type
1 | include <cstdio>
| ^~~~~~~
In file included from /usr/include/c++/14/cmath:45,
from a.cc:5:
/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,
from /usr/include/c++/14/bits/specfun.h:43,
from /usr/include/c++/14/cmath:3906:
/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 'time_t'?
1429 | : public integral_constant<std::size_t, alignof(_Tp)>
| ^~~~~~
| time_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 'time_t'?
1438 | : public integral_constant<std::size_t, 0> { };
| ^~~~~~
| time_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 'time_t'?
1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
| time_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 'time_t'?
1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
| ^~~~~~
| time_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 declared in this scope
156 | using difference_type = __detected_or_t<ptrdiff_t, __diff_t, _Ptr>;
| ^~~~~~~~~
/usr/include/c++/14/bits/ptr_traits.h:1:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
+++ |+#include <cstddef>
1 | // Pointer Traits -*- C++ -*-
/usr/include/c++/14/bits/ptr_traits.h:156:72: error: template argument 1 is invalid
156 | using difference_type = __detected_or_t<ptrdiff_t, __diff_t, _Ptr>;
|
s178721418 | p03659 | C++ | #include<stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
long long int abs(long long int a)
{
if(a<=0)
return -a;
else
return a;
}
long long int a[100005];
int main()
{
long long int sum=0;
int n;
cin>>n;
for(int i=0;i<n;i++)
{
cin>>a[i];
sum+=a[i];
}
long long int ans=a[0];
long long int d=abs(2*ans-sum);
long long int t;
for(int i=1;i<n-1;i++)
{
ans+=a[i];
t=abs(2*ans-sum);
if(t<d)
{
d=t;
}
else
{
break;
}
}
cout<<d<<endl;
}
| a.cc:5:34: error: 'long long int abs(long long int)' conflicts with a previous declaration
5 | long long int abs(long long int a)
| ^
In file included from /usr/include/c++/14/cstdlib:81,
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/c++/14/bits/std_abs.h:61:3: note: previous declaration 'long long int std::abs(long long int)'
61 | abs(long long __x) { return __builtin_llabs (__x); }
| ^~~
a.cc: In function 'int main()':
a.cc:24:24: error: call of overloaded 'abs(long long int)' is ambiguous
24 | long long int d=abs(2*ans-sum);
| ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/cstdlib:79:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
/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:5:15: note: candidate: 'long long int abs(long long int)'
5 | long long int abs(long long int a)
| ^~~
a.cc:29:14: error: call of overloaded 'abs(long long int)' is ambiguous
29 | t=abs(2*ans-sum);
| ~~~^~~~~~~~~~~
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
/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:5:15: note: candidate: 'long long int abs(long long int)'
5 | long long int abs(long long int a)
| ^~~
|
s433616780 | p03659 | C++ | #include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
using namespace std;
#define ul unsigned long long
#define lol long long
#define rup(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define rdn(i, a, b) for(int (i) = (a); (i) > (b); (i)--)
vector<lol> a;
lol sum(lol begin, lol end) {
lol sum = 0;
for (lol i = begin; i < end; i++) {
sum += a[i];
}
return sum;
}
int main() {
int n;
cin >> n;
a = vector<lol>(n, 0);
rup(i, 0, n) cin >> a[i];
lol s = lol(ceil(n / 2));
lol x = sum(0, s);
lol y = sum(s, n);
lol eva = abs(x - y);
if (n != 2) {
while (1) {
lol nx = x;
lol ny = y;
lol ns = s;
if (x > y) {
nx -= a[ns - 1];
ny += a[ns - 1];
ns--;
}
else {
nx += a[ns];
ny -= a[ns];
ns++;
}
lol newEva = abs(nx - ny);
if (newEva < eva) {
x = nx;
y = ny;
s = ns;
eva = newEva;
}
else {
break;
}
}
}
cout << eva;
return 0;
}
| a.cc: In function 'int main()':
a.cc:14:13: error: expected primary-expression before 'long'
14 | #define lol long long
| ^~~~
a.cc:34:17: note: in expansion of macro 'lol'
34 | lol s = lol(ceil(n / 2));
| ^~~
|
s288832064 | p03659 | C++ | #include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include <algorithm>
#include<initializer_list>
using namespace std;
#define ul unsigned long long
#define lol long long
#define rup(i, a, b) for(int (i) = (a); (i) < (b); (i)++)
#define rdn(i, a, b) for(int (i) = (a); (i) > (b); (i)--)
vector<lol> a;
//lol bin(lol begin, lol end) {
// // a[begin]からa[floor(end/2)]の総和とa[floor(end/2)]からa[end]までの総和の差を返す。
// // a[begin]からa[end]を2分割したとき、
// // それぞれの総和が最小となる添え字
// // それぞれの総和
// // を返す。
//}
//lol bin2(lol begin, lol ned){
////aの添え字beginとendを与えると、begin~floor(end/2)の総和とfloor(end / 2 + 1)~endの総和を比較して、
////beginからのほうが大きければbeginを、floor(end / 2 + 1)からの方が大きければfloor(end / 2 + 1)を返す
//}
//lol binSearch(lol begin, lol end, leftSum, rightSum) {
// //aの添え字beginとendを与えると、aを2分割したときそれぞれの総和が最も小さくなるような添え字を返す。
// lol leftSum = sum(begin, floor(end / 2));
// lol rightSum = sum(floor(end / 2), end);
// if (leftSum > rightSum) {
// binSearch(begin, floor(end / 2));
// }
// else {
// binSearch(floor(end / 2), end);
// }
//}
//lol bin(lol separate, lol x, lol y) {
// //vector aを2分割したとき、それぞれの総和が最も近くなるような添え字を返す。
// // 再起関数。separateにははじめfloor((a.size())/2)を渡す。xとyはaをseparateで分けたときの、それぞれの部分和
// if (x > y) {
// lol s = floor(separate / 2);
// }
//
//}
lol sum(lol begin, lol end) {
lol sum = 0;
for (lol i = begin; i < end; i++) {
sum += a[i];
}
return sum;
}
int main() {
int n;
cin >> n;
a = vector<lol>(n, 0);
rup(i, 0, n) cin >> a[i];
lol s = lol(ceil(n / 2));
lol x = sum(0, s);
lol y = sum(s, n);
lol eva = abs(x-y);
if (n != 2) {
while (1) {
lol nx = x;
lol ny = y;
lol ns = s;
if (x > y) {
nx -= a[ns - 1];
ny += a[ns - 1];
ns--;
}
else {
nx += a[ns];
ny -= a[ns];
ns++;
}
lol newEva = abs(nx - ny);
if (newEva < eva) {
x = nx;
y = ny;
s = ns;
eva = newEva;
}
else {
break;
}
}
}
cout << eva;
return 0;
}
| a.cc: In function 'int main()':
a.cc:14:13: error: expected primary-expression before 'long'
14 | #define lol long long
| ^~~~
a.cc:63:17: note: in expansion of macro 'lol'
63 | lol s = lol(ceil(n / 2));
| ^~~
|
s295264526 | p03659 | C++ | #include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
int n,a[100],b[100];
int sum=0;
int z=0,x=0,y=0;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
sum=sum+a[i];
}
sort(a,a+n);
for(int j=1;j<n;j++)
{
x=0;
y=0;
for(int i=0;i<j;i++)
{
x=x+a[i];
}
y=sum-x;
b[z]=abs(x-y);
z++;
}
sort(b,b+z);
cout<<b[0]<<"\n";
return 0;
} | a.cc: In function 'int main()':
a.cc:16:9: error: 'sort' was not declared in this scope; did you mean 'sqrt'?
16 | sort(a,a+n);
| ^~~~
| sqrt
|
s085744696 | p03659 | C++ | #include <algorithm>
#include <iostream>
#include <set>
#include <string>
#include <sstream>
#include <vector>
#include <cmath>
#include <cstdio>
#include <chrono>
#include <unordered_map>
using namespace std;
typedef long long int ll;
typedef int h_int;
#define REP(i, n) for(int i = 0; i < ( n ); ++i )
#define REPR(i, n) for(int i = ( n ); i >= 0; --i)
#define FOR(i, a, n) for(int i = ( a ); i < ( n ); ++i )
#define FORR(i, a, n) for(int i = ( n ); i >= ( a ); --i)
#define DOUT(x) cerr << #x << " = " << x << "\n";
#define COUT(x) cout << ( x ) << "\n";
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n; cin >> n;
vector<ll> a;
a.resize(n);
ll sum = 0;
REP(i, n)
{
cin >> a[i];
sum += a[i];
}
int x = a[0];
int y = sum - x;
ll m = abs(x - y);
FOR(i, 1, n - 1)
{
x += a[i];
y = sum - x;
m = min(m, abs(x - y) );
}
std::cout << m << '\n';
return 0;
}
| a.cc: In function 'int main()':
a.cc:49:24: error: no matching function for call to 'min(ll&, int)'
49 | m = min(m, abs(x - y) );
| ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
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:49:24: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
49 | m = min(m, abs(x - y) );
| ~~~^~~~~~~~~~~~~~~~
/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:49:24: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
49 | m = min(m, abs(x - y) );
| ~~~^~~~~~~~~~~~~~~~
|
s563217361 | p03659 | C++ | #include <cstdio>
2.#include <iostream>
3.using namespace std;
4. int n,a[200002];
5.int main(){
6. scanf("%d",&n);
7. long long sum=0;
8. for(int i=1;i<=n;++i){
9. scanf("%d",&a[i]);
10. sum+=a[i];
11. }
12. long long s=0,ans=200000000000000LL;
13. for(int i=1;i<n;++i){
14. s+=a[i];
15. ans=min(ans,abs(sum-s-s));
16. }
17. cout<<ans;
18.}
| a.cc:2:3: error: stray '#' in program
2 | 2.#include <iostream>
| ^
a.cc:2:1: error: expected unqualified-id before numeric constant
2 | 2.#include <iostream>
| ^~
a.cc:4:1: error: expected unqualified-id before numeric constant
4 | 4. int n,a[200002];
| ^~
a.cc:5:1: error: expected unqualified-id before numeric constant
5 | 5.int main(){
| ^~~~~
|
s672372773 | p03659 | C++ | #include <cstdio>
#include <iostream>
using namespace std;
int main(){
scanf("%d",&n);
long long sum=0;
for(int i=1;i<=n;++i){
scanf("%d",&a[i]);
sum+=a[i];
}
long long s=0,ans=200000000000000LL;
for(int i=1;i<n;++i){
s+=a[i];
ans=min(ans,abs(sum-s-s));
}
cout<<ans;
} | a.cc: In function 'int main()':
a.cc:6:17: error: 'n' was not declared in this scope
6 | scanf("%d",&n);
| ^
a.cc:9:21: error: 'a' was not declared in this scope
9 | scanf("%d",&a[i]);
| ^
a.cc:14:12: error: 'a' was not declared in this scope
14 | s+=a[i];
| ^
|
s361778871 | p03659 | C++ | #include <algorithm>
#include <iostream>
using namespace std;
int main(){
long long int N,a[200000],yan[200000],yojo[200000];
long long int min=2000000000,s;
cin>>N;
for(int i=0;i<N;i++){
cin>>a[i];
}
for(int j=0;j<N;j++){
for(int k=0;k<j;k++){
yan[j]+=a[k];
}
}
for(int p=0;p<N;p++){
for(int q=N;q>p;q--){
yojo[p]+=a[q];
}
}
for(int g=0;g<N;g++){
s=yan[g]-yojo[g];
if(s<0){
s=s*-1;
}
if(min>s){
min=s
}
}
cout<<s<<endl;
} | a.cc: In function 'int main()':
a.cc:28:6: error: expected ';' before '}' token
28 | min=s
| ^
| ;
29 | }
| ~
|
s974496411 | p03659 | C | #include <stdio.h>
#include <stdlib.h>
//abs(int x)
int main()
{
long sum = 0;
long dif;
int N;
scanf("%d", &N);
int a[N];
for(int i = 0; i < N; i++){
scanf("%d", &a[i]);
}
int b[N];
for(int i = 0; i < N-1; i++){
b[i] = 0;
for(int p = 0; p <= i; p++){
b[i] += a[p];
}
sum += a[i];
}
sum += a[N-1];
for(int i = 0; i < N-1; i++){
if(i == 0) dif = labs(2*b[i] - sum);
if(labs(2*b[i] - sum) < dif){
dif = labs();
}
}
printf("%ld", dif);
return 0;
}
| main.c: In function 'main':
main.c:27:13: error: too few arguments to function 'labs'
27 | dif = labs();
| ^~~~
In file included from main.c:2:
/usr/include/stdlib.h:981:17: note: declared here
981 | extern long int labs (long int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~~
|
s524812427 | p03659 | C++ | // VSのおまじない
#define _CRT_SECURE_NO_WARNINGS 0
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
void problem_a(void);
void problem_b(void);
void problem_c(void);
// メイン関数
int main(void) {
problem_c();
return 0;
}
void problem_a(void) {
int a, b;
//入力
scanf("%d %d",&a,&b);
// 3匹のヤギが同じ枚数食べられるか?
if ((a + b) % 3 == 0 || a%3 ==0 || b%3==0) {
printf("Possible");
}
else {
printf("Impossible");
}
return;
}
void problem_b(void) {
int n,k;
int *len;
int sum = 0;
int i, j;
//入力
scanf("%d %d", &n, &k);
//
len = (int*)malloc(n*sizeof(int));
for (i = 0; i < n; i++) {
scanf("%d", &len[i]);
}
// 降順ソート
for (i = 0; i < n - 1; i++) {
for (j = i + 1; j < n; j++) {
if (len[i] < len[j]) {
int temp = len[i];
len[i] = len[j];
len[j] = temp;
}
}
}
// 長さの大きいものから足していく
for (i = 0; i < k; i++) {
sum += len[i];
}
printf("%d", sum);
free(len);
return;
}
void problem_c(void) {
int n;
int *ai;
int sum_s = 0;
int sum_a = 0;
int result;
int min = INT_MAX;
int i, j;
// 入力
scanf("%d", &n);
// カードの入力
ai = (int*)malloc(n*sizeof(int));
for (i = 0; i < n; i++) {
scanf("%d", &ai[i]);
}
// 結果をすべて求める
for (i = 0; i < n - 1; i++) {
sum_s = 0;
for (j = 0; j <= i; j++) {
sum_s += ai[j];
}
sum_a = 0;
for (j = i + 1; j < n; j++) {
sum_a += ai[j];
}
result = abs(sum_s - sum_a);
if (result < min) {
min = result;
}
}
printf("%d",min);
free(ai);
return;
} | a.cc: In function 'void problem_c()':
a.cc:82:19: error: 'INT_MAX' was not declared in this scope
82 | int min = INT_MAX;
| ^~~~~~~
a.cc:7:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
6 | #include<math.h>
+++ |+#include <climits>
7 |
|
s448166473 | p03659 | C++ | //2016.7.15
//ABC 067 (C)
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
long long int n,a=0,b=0, ans;
cin >> n;
vector <long long int> A(n);
for (int i = 0; i < n; i++) {
cin >> A[i];
}
sort(A.begin(), A.end());
n--;
a=A[n];
while(n>0){
n--;
if(a>b){ if(A[n]>0) { b+=A[n];}
else {a+=A[n];}
}
else { if(A[n]>0) {a+=A[n];}
else {b+=A[n];}
}
if(a>=b) ans=a-b;
else ans=b-a;
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:33:2: error: expected '}' at end of input
33 | }
| ^
a.cc:10:12: note: to match this '{'
10 | int main() {
| ^
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.