submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3
values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s989284843 | p03658 | C++ | #include <iostream>
#include <vector>
#include <numeric>
int main(int argc, char const *argv[]) {
int N,K;
std::cin >> N >> K;
std::vector<int> snake_bodys;
for(int times = 0 ; times < N ; times++ )
{
int snake_body_length;
std::cin >> snake_body_length;
snake_bodys.push_back(snake_body_length);
}
std::sort(snake_bodys.begin(),snake_bodys.end(),std::greater<int>());
int snake_length = 0;
snake_length = std::accumulate(snake_bodys.begin(), snake_bodys.begin()+K,0);
std::cout << snake_length << '\n';
return 0;
}
| a.cc: In function 'int main(int, const char**)':
a.cc:18:10: error: 'sort' is not a member of 'std'; did you mean 'qsort'?
18 | std::sort(snake_bodys.begin(),snake_bodys.end(),std::greater<int>());
| ^~~~
| qsort
|
s001782859 | p03658 | C++ | include<bits/stdc++.h>
using namespace std;
int n,k;
int l[51];
int main(){
int ans=0;
cin>>n>>k;
for(int i=0;i<n;i++){
cin>>l[i];
}
sort(l,l+n);
for(int i=n;i>=n-k;i--){
ans+=l[i];
}
cout<<ans<<endl;
return 0;
}
| a.cc:1:1: error: 'include' does not name a type
1 | include<bits/stdc++.h>
| ^~~~~~~
a.cc: In function 'int main()':
a.cc:7:5: error: 'cin' was not declared in this scope
7 | cin>>n>>k;
| ^~~
a.cc:11:5: error: 'sort' was not declared in this scope; did you mean 'short'?
11 | sort(l,l+n);
| ^~~~
| short
a.cc:15:5: error: 'cout' was not declared in this scope
15 | cout<<ans<<endl;
| ^~~~
a.cc:15:16: error: 'endl' was not declared in this scope
15 | cout<<ans<<endl;
| ^~~~
|
s530047444 | p03658 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
int main()
{
int n, k, v[105];
cin >> n >> k;
for(int i = 0; i < n; ++i)
cin >> v[i];
sort(v, v + n);
int ans = 0, now = n - 1;
while(k--)
{
ans += v[i];
--now;
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:16:18: error: 'i' was not declared in this scope
16 | ans += v[i];
| ^
|
s179520306 | p03658 | C++ | #include <iostream>
#include <algorithm>
#include <array>
#include <math.h>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#define INT_MAX 2000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define vsort(x) sort(x.begin(),x.end())
using namespace std;
int main() {
int i, j, k;
int n, k;
int l[50];
cin >> n >> k;
rep(i, 0, n)
cin >> l[i];
sort(l, l + n);
int ans = 0;
rep(i, 0, k) {
ans += l[n - 1 - i];
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:23:16: error: redeclaration of 'int k'
23 | int n, k;
| ^
a.cc:22:19: note: 'int k' previously declared here
22 | int i, j, k;
| ^
|
s370472854 | p03658 | C++ | package Kadai;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
public class Sort {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] x = br.readLine().split(" ");
int a = Integer.parseInt(x[0]);
int b = Integer.parseInt(x[1]);
String[] line = br.readLine().split(" ");
int[] ia = new int[a];
int c = 0;
for (int i = 0; i < a; i++) {
ia[i] = Integer.parseInt(line[i]);
}
Arrays.sort(ia);
for (int i = a - 1; i < a + b; i--) {
c = c + ia[i];
System.out.println(c);
}
System.out.println(c);
}
} | a.cc:1:1: error: 'package' does not name a type
1 | package Kadai;
| ^~~~~~~
a.cc:3:1: error: 'import' does not name a type
3 | import java.io.BufferedReader;
| ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
4 | import java.io.InputStreamReader;
| ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
5 | import java.util.Arrays;
| ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:1: error: expected unqualified-id before 'public'
7 | public class Sort {
| ^~~~~~
|
s045407506 | p03658 | C++ | //-------------
//include
//-------------
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <vector>
#include <string>
#include <cctype>
#include <random>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <algorithm>
using namespace std;
//-------------
//typedef
//-------------
typedef long long LL;
typedef vector<int> VI;
typedef set<int> SI;
typedef string STR;
typedef pair<int, int> PII;
typedef vector<int, int> VII;
typedef map<string, int> MSI;
//-------------
//utillty
//-------------
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MK make_pair
#define PB push_back
#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())
#define COUT(a) cout<<a<<endl
//-------------
//repetition
//-------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
//-------------
//debug
//-------------
#define dump(x) cerr << #x << " = " << (x) << endl;
#define dumpl(c) REP(i,SZ(c))cerr<<#c<<i<<"="<<(c[i])<<endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int MOD = 1000000007;
int main()
{
int N,K;
cin >>N>>K;
VI A;
REP(i,N)
{
int temp;
cin >> temp;
A.push_back(temp);
}
SORT(A);
COUT(accumulate(A[K-1],A.end(),0));
#ifdef _DEBUG
while (1);
#endif // _DEBUG
return 0;
} | a.cc: In function 'int main()':
a.cc:64:24: error: no matching function for call to 'accumulate(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, std::vector<int>::iterator, int)'
64 | COUT(accumulate(A[K-1],A.end(),0));
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~
a.cc:38:23: note: in definition of macro 'COUT'
38 | #define COUT(a) cout<<a<<endl
| ^
In file included from /usr/include/c++/14/numeric:62,
from /usr/include/c++/14/bits/random.tcc:33,
from /usr/include/c++/14/random:50,
from a.cc:11:
/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:64:24: note: deduced conflicting types for parameter '_InputIterator' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >')
64 | COUT(accumulate(A[K-1],A.end(),0));
| ~~~~~~~~~~^~~~~~~~~~~~~~~~~~
a.cc:38:23: note: in definition of macro 'COUT'
38 | #define COUT(a) cout<<a<<endl
| ^
/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
|
s497169309 | p03658 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int N,K,L,tmp;
L=0;
cin >> N >> K;
int l[N];
for(int i=0;i<=N;i++){
cin >> N[0];
}
for(i=0; i<N; ++i) {
for (j=i+1; j<N; ++j) {
if (l[i] < l[j]) {
tmp = l[i];
l[i] = l[j];
l[j] = tmp;
}
}
}
for(int i=0;i<K;i++){
L=L+N[i];
}
cout << L << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:10:11: error: invalid types 'int[int]' for array subscript
10 | cin >> N[0];
| ^
a.cc:13:7: error: 'i' was not declared in this scope
13 | for(i=0; i<N; ++i) {
| ^
a.cc:14:10: error: 'j' was not declared in this scope
14 | for (j=i+1; j<N; ++j) {
| ^
a.cc:24:8: error: invalid types 'int[int]' for array subscript
24 | L=L+N[i];
| ^
|
s524261488 | p03658 | C++ | #include <bits/stdc++.h>
using namespace std;
int main{
int N,K,L,tmp;
L=0;
cin >> N >> K;
int l[N];
for(int i=0;i<=N;i++){
cin >> N[0];
}
for(i=0; i<N; ++i) {
for (j=i+1; j<N; ++j) {
if (l[i] < l[j]) {
tmp = l[i];
l[i] = l[j];
l[j] = tmp;
}
}
}
for(int i=0;i<K;i++){
L=L+N[i];
}
cout << L << endl;
return 0;
} | a.cc:4:5: error: cannot declare '::main' to be a global variable
4 | int main{
| ^~~~
a.cc:5:3: error: expected primary-expression before 'int'
5 | int N,K,L,tmp;
| ^~~
a.cc:5:3: error: expected '}' before 'int'
a.cc:4:9: note: to match this '{'
4 | int main{
| ^
a.cc:6:3: error: 'L' does not name a type
6 | L=0;
| ^
a.cc:7:3: error: 'cin' does not name a type
7 | cin >> N >> K;
| ^~~
a.cc:8:9: error: 'N' was not declared in this scope
8 | int l[N];
| ^
a.cc:9:3: error: expected unqualified-id before 'for'
9 | for(int i=0;i<=N;i++){
| ^~~
a.cc:9:15: error: 'i' does not name a type
9 | for(int i=0;i<=N;i++){
| ^
a.cc:9:20: error: 'i' does not name a type
9 | for(int i=0;i<=N;i++){
| ^
a.cc:13:3: error: expected unqualified-id before 'for'
13 | for(i=0; i<N; ++i) {
| ^~~
a.cc:13:12: error: 'i' does not name a type
13 | for(i=0; i<N; ++i) {
| ^
a.cc:13:17: error: expected unqualified-id before '++' token
13 | for(i=0; i<N; ++i) {
| ^~
a.cc:23:3: error: expected unqualified-id before 'for'
23 | for(int i=0;i<K;i++){
| ^~~
a.cc:23:15: error: 'i' does not name a type
23 | for(int i=0;i<K;i++){
| ^
a.cc:23:19: error: 'i' does not name a type
23 | for(int i=0;i<K;i++){
| ^
a.cc:27:3: error: 'cout' does not name a type
27 | cout << L << endl;
| ^~~~
a.cc:29:3: error: expected unqualified-id before 'return'
29 | return 0;
| ^~~~~~
a.cc:30:1: error: expected declaration before '}' token
30 | }
| ^
|
s023077815 | p03658 | C++ | #include <bits/stdc++.h>
using namespace std;
int main{
int N,K,L,tmp;
L=0;
cin >> N >> K;
int l[N];
for(int i=0;i<=N;i++){
cin >> N[0];
}
cin >> endl;
for (i=0; i<N; ++i) {
for (j=i+1; j<N; ++j) {
if (l[i] < l[j]) {
tmp = l[i];
l[i] = l[j];
l[j] = tmp;
}
}
}
for(int i=0;i<K;i++){
L=L+N[i];
}
cout << L;
return 0;
} | a.cc:4:5: error: cannot declare '::main' to be a global variable
4 | int main{
| ^~~~
a.cc:5:3: error: expected primary-expression before 'int'
5 | int N,K,L,tmp;
| ^~~
a.cc:5:3: error: expected '}' before 'int'
a.cc:4:9: note: to match this '{'
4 | int main{
| ^
a.cc:6:3: error: 'L' does not name a type
6 | L=0;
| ^
a.cc:7:3: error: 'cin' does not name a type
7 | cin >> N >> K;
| ^~~
a.cc:8:9: error: 'N' was not declared in this scope
8 | int l[N];
| ^
a.cc:9:3: error: expected unqualified-id before 'for'
9 | for(int i=0;i<=N;i++){
| ^~~
a.cc:9:15: error: 'i' does not name a type
9 | for(int i=0;i<=N;i++){
| ^
a.cc:9:20: error: 'i' does not name a type
9 | for(int i=0;i<=N;i++){
| ^
a.cc:12:3: error: 'cin' does not name a type
12 | cin >> endl;
| ^~~
a.cc:14:3: error: expected unqualified-id before 'for'
14 | for (i=0; i<N; ++i) {
| ^~~
a.cc:14:13: error: 'i' does not name a type
14 | for (i=0; i<N; ++i) {
| ^
a.cc:14:18: error: expected unqualified-id before '++' token
14 | for (i=0; i<N; ++i) {
| ^~
a.cc:24:3: error: expected unqualified-id before 'for'
24 | for(int i=0;i<K;i++){
| ^~~
a.cc:24:15: error: 'i' does not name a type
24 | for(int i=0;i<K;i++){
| ^
a.cc:24:19: error: 'i' does not name a type
24 | for(int i=0;i<K;i++){
| ^
a.cc:28:3: error: 'cout' does not name a type
28 | cout << L;
| ^~~~
a.cc:30:3: error: expected unqualified-id before 'return'
30 | return 0;
| ^~~~~~
a.cc:31:1: error: expected declaration before '}' token
31 | }
| ^
|
s128750207 | p03658 | C | #include <iostream>
using namespace std;
int main(){
int k,i,j,n,l[100];
cin >> n >> k;
for(i=0;i<n;i++)cin >> l[i];
for(i=0;i<n;i++){
for(j=0;j<n-i;j++){
if(l[j]<l[j+1]) swap(l[j],l[j+1]);
}
}
//for(int i=0;i<n;i++)cout << l[i] << endl;
int sum=0;
// cout << sum << endl;
for(i=0;i<k;i++)sum+=l[i];
cout << sum << endl;
return 0;
}
| main.c:1:10: fatal error: iostream: No such file or directory
1 | #include <iostream>
| ^~~~~~~~~~
compilation terminated.
|
s890376344 | p03658 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int N,K;
cin>>N>>K;
vector<int> Stick(N);
for(int i = 0; i < N; i++)
{
cin>>Stick[i];
}
sort(Stick.rbegin(),Stick.rend());
long long ans = 0;
for(inti i = 0; i < K; i++)
{
ans+=Stick[i];
}
cout<<ans;
return 0;
} | a.cc: In function 'int main()':
a.cc:16:5: error: 'inti' was not declared in this scope; did you mean 'int'?
16 | for(inti i = 0; i < K; i++)
| ^~~~
| int
a.cc:16:17: error: 'i' was not declared in this scope
16 | for(inti i = 0; i < K; i++)
| ^
|
s056659536 | p03658 | Java | import java.util.Scanner;
public class B {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
int[] lengths = new int[n];
for (int i = 0; i < n; i++) {
lengths[i] = sc.nextInt();
}
sc.close();
// now we need a way of sorting through all of the sticks
int ans = 0;
for (int i = 0; i < k; i++) {
int temp = 0;
for (int j = 0; j < n; j++) {
if (lengths[j] >= lengths[temp]) {
temp = j;
// we also need a way of removing the maximum here
}
}
ans += lengths[temp];
lengths[temp] = 0;
}
System.out.println(ans);
}
}
| Main.java:3: error: class B is public, should be declared in a file named B.java
public class B {
^
1 error
|
s787347416 | p03658 | C++ |
#include <iostream>
#include <vector>
#define loop(i, num) for (int i = 0; i < num; i++)
using namespace std;
int main() {
int a, b, ans = 0;
cin >> a >> b;
vector<int> n(a);
loop (i, a) cin >> n[i];
sort(n.begin(), n.end());
loop (i, b) ans += n[a - i - 1];
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:19:5: error: 'sort' was not declared in this scope; did you mean 'short'?
19 | sort(n.begin(), n.end());
| ^~~~
| short
|
s620442893 | p03658 | C | #include <stdio.h>
int main(void)
{
int n,k,l,i,j,tot[5],sum=0,x;
scanf("%d%d",&n,&k);
for(i=0;i<n;i++)
{
scanf("%d",&l);
tot[i]=l;
}
for(i=0;i<n-1;i++)
for(j=n-1;j>=i;j--)
if(tot[i]>tot[i-1])
{
x=tot[j];
tot[j]=tot[j-1];
tot[j-1]=x;
}
for(i=0;i<k;i++)
sum+=tot[i];
printf("\n%d",sum);
return 0;
| main.c: In function 'main':
main.c:22:5: error: expected declaration or statement at end of input
22 | return 0;
| ^~~~~~
|
s474031899 | p03658 | C | #include<bits/stdc++.h>
using namespace std;
int ara[1000];
int main()
{
int i,j,k,l,n,t,df,v;
while(scanf("%d %d",&n,&k)!=EOF)
{
for(i=1;i<=n;i++)
{
scanf("%d",&ara[i]);
}
sort(ara,ara+n);
int sum=0;
for(i=n;i>n-k;i--)
{
sum+=ara[i];
}
printf("%d\n",sum);
}
return 0;
}
| main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
1 | #include<bits/stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s823983095 | p03658 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int n,k;
int ans = 0;
cin >> n >> k;
vector<int> l(n);
for(int i = 0; i < n; i++){
cin >> l[i];
}
sort(l.begin(),l.end(),greater<int>();
for(int j = 0; j < k; j++){
ans += l[j];
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:15:40: error: expected ')' before ';' token
15 | sort(l.begin(),l.end(),greater<int>();
| ~ ^
| )
|
s509385069 | p03658 | C++ | #include<iostream>
#include<vector>
using namespace std;
int main() {
int N,K,l;
cin >> N >> K;
int ls[N];
for(int i=0; i<N; ++i) {
cin >> ls[i];
}
sort(ls, ls+N);
int sum_num = 0;
for(int i=N-1; i > N-K-1; --i) {
//cout << ls[i] << " ";
sum_num += ls[i];
}
cout << sum_num << endl;
//cout << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:13:5: error: 'sort' was not declared in this scope; did you mean 'short'?
13 | sort(ls, ls+N);
| ^~~~
| short
|
s943951032 | p03658 | C++ | #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
int arr[55]
for(int i=0;i<n;i++){
cin>>arr[i];
}
int sum=0;
sort(arr,arr+n);
for(int i=0;i<k;i++){
sum+=arr[i];
}
cout<<sum;
}
| a.cc: In function 'int main()':
a.cc:13:5: error: expected initializer before 'for'
13 | for(int i=0;i<n;i++){
| ^~~
a.cc:13:17: error: 'i' was not declared in this scope
13 | for(int i=0;i<n;i++){
| ^
a.cc:17:10: error: 'arr' was not declared in this scope
17 | sort(arr,arr+n);
| ^~~
|
s110535769 | p03658 | C++ | #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
int arr[55]
for(int i=0;i<n;i++){
cin>>arr[i];
}
int sum=0;
sort(arr,arr+n)
for(int i=0;i<k;i++){
sum+=arr[i];
}
cout<<sum;
}
| a.cc: In function 'int main()':
a.cc:13:5: error: expected initializer before 'for'
13 | for(int i=0;i<n;i++){
| ^~~
a.cc:13:17: error: 'i' was not declared in this scope
13 | for(int i=0;i<n;i++){
| ^
a.cc:17:10: error: 'arr' was not declared in this scope
17 | sort(arr,arr+n)
| ^~~
|
s001323666 | p03658 | C++ | #include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map>
#include <map>
#include <numeric>
#include <limits>
#include <utility>
using namespace std;
typedef long long longlong;
typedef long long LL;
typedef pair<int, pair<int, int>> Trio;
typedef pair<int, int> Pair;
int main(void) {
int n,k,ma=0
cin >>n>>k;
vector<int> l(n);
for(int i=0;i<n;i++){
cin >>l[i];
}
sort(l.begin(),l.end(),greater<int>());
for(int i=0;i<k;i++){
ma+=l[i];
}
cout <<ma<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:21:9: error: expected ',' or ';' before 'cin'
21 | cin >>n>>k;
| ^~~
|
s867877804 | p03658 | C++ | #include<iostream>
#include<algorithm>
using nemspace std;
int main(){
int n,k;cin >> n >> k;
int a[100000];
for(int i=0; i<n; i++)cin >> a[i];
sort(a,a+n);
itn ans=0;
for(int i=0; i<k; i++)ans+=a[i];
cout << ans << endl;
return 0;
} | a.cc:3:7: error: expected nested-name-specifier before 'nemspace'
3 | using nemspace std;
| ^~~~~~~~
a.cc: In function 'int main()':
a.cc:5:10: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
5 | int n,k;cin >> n >> k;
| ^~~
| std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:8:2: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
8 | sort(a,a+n);
| ^~~~
| std::sort
In file included from /usr/include/c++/14/algorithm:86,
from a.cc:2:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
| ^~~~
a.cc:9:2: error: 'itn' was not declared in this scope; did you mean 'int'?
9 | itn ans=0;
| ^~~
| int
a.cc:10:24: error: 'ans' was not declared in this scope; did you mean 'abs'?
10 | for(int i=0; i<k; i++)ans+=a[i];
| ^~~
| abs
a.cc:11:2: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
11 | cout << ans << endl;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:11:10: error: 'ans' was not declared in this scope; did you mean 'abs'?
11 | cout << ans << endl;
| ^~~
| abs
a.cc:11:17: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
11 | cout << ans << endl;
| ^~~~
| std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
|
s374584772 | p03658 | C++ | #include <iostream>
#include <algorithm>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
int n, k;
cin >> n >> k;
vector<int> a(n);
for(int i=0; i<n; i++) cin >> a[i];
sort(a.begin(), a.end(), greater<int>());
int sum = 0;
for(int i=0; i<k; i++) sum += a[i];
cout << sum << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:14:5: error: 'vector' was not declared in this scope
14 | vector<int> a(n);
| ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
2 | #include <algorithm>
+++ |+#include <vector>
3 |
a.cc:14:12: error: expected primary-expression before 'int'
14 | vector<int> a(n);
| ^~~
a.cc:15:35: error: 'a' was not declared in this scope
15 | for(int i=0; i<n; i++) cin >> a[i];
| ^
a.cc:17:10: error: 'a' was not declared in this scope
17 | sort(a.begin(), a.end(), greater<int>());
| ^
|
s156556895 | p03658 | C++ | #include <iostream>
#include <algorithm>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
int n, k;
cin >> n >> k;
vector<int> a(n);
for(int i=0; i<n; i++) cin >> a[i];
sort(a.begin(), a.end());
int sum = 0;
for(int i=k; i>0; i--) sum += a[i];
cout << sum << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:14:5: error: 'vector' was not declared in this scope
14 | vector<int> a(n);
| ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
2 | #include <algorithm>
+++ |+#include <vector>
3 |
a.cc:14:12: error: expected primary-expression before 'int'
14 | vector<int> a(n);
| ^~~
a.cc:15:35: error: 'a' was not declared in this scope
15 | for(int i=0; i<n; i++) cin >> a[i];
| ^
a.cc:17:10: error: 'a' was not declared in this scope
17 | sort(a.begin(), a.end());
| ^
|
s324416421 | p03658 | C++ | #include <iostream>
#include <algorithm>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
int n, k;
cin >> n >> k;
vector<int> a(n);
for(int i=0; i<n; i++) cin >> a[i];
sort(a.begin(), a.end());
int sum = 0;
for(int i=k; i>0; i--) sum += a[i];
cout << sum << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:14:5: error: 'vector' was not declared in this scope
14 | vector<int> a(n);
| ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
2 | #include <algorithm>
+++ |+#include <vector>
3 |
a.cc:14:12: error: expected primary-expression before 'int'
14 | vector<int> a(n);
| ^~~
a.cc:15:35: error: 'a' was not declared in this scope
15 | for(int i=0; i<n; i++) cin >> a[i];
| ^
a.cc:17:10: error: 'a' was not declared in this scope
17 | sort(a.begin(), a.end());
| ^
|
s360716067 | p03658 | C++ |
#include <iostream>
#include <vector>
using namespace std;
int main() {
int n,k,ans=0;
cin >> n >> k;
vector<int> l(n,0);
for(int i = 0;i < n;i++){
cin >> l[i];
}
sort(l.begin(), l.end(), greater<int>());
for(int i = 0;i < k;i++){
ans += l[i];
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:13:5: error: 'sort' was not declared in this scope; did you mean 'short'?
13 | sort(l.begin(), l.end(), greater<int>());
| ^~~~
| short
|
s233670844 | p03658 | C | #include<stdio.h>
int main(){
int N, K, i, j, t, sum;
int l[51];
scanf("%d %d",&N,&K);
for(i = 0; i < N; i++){
scanf("%d", &l[i]);
}
for(i = 0; i < K; i++){
for(j = 0; j < N; j++){
if(l[t] < l[j]){
temp = j;
}
}
sum += l[t];
l[t] = 0;
}
printf("%d",sum);
return 0;
} | main.c: In function 'main':
main.c:17:9: error: 'temp' undeclared (first use in this function)
17 | temp = j;
| ^~~~
main.c:17:9: note: each undeclared identifier is reported only once for each function it appears in
|
s535815303 | p03658 | C++ | #include <iostream>
#include <vector>
using namespace std;
int main(int argc, char const *argv[])
{
int N, K;
cin >> N >> K;
vector<int> nums(N);
for(int i = 0; i < N; i++){
cin >> nums[i];
}
sort(nums.begin() , nums.end());
int res = 0;
for(int i = N - K; i < N; i++){
res += nums[i];
}
cout << res << endl;
return 0;
} | a.cc: In function 'int main(int, const char**)':
a.cc:14:9: error: 'sort' was not declared in this scope; did you mean 'short'?
14 | sort(nums.begin() , nums.end());
| ^~~~
| short
|
s072821553 | p03658 | C++ | #include <iostream>
using namespace std;
typedef long long ll;
int n, k;
int arr[51];
int main(int argc, const char * argv[]) {
ios_base::sync_with_stdio(false);
cin >> n >> k;
for(int i =0 ; i < n; i ++){
cin >> arr[i];
}
sort(arr, arr + n);
int ret =0 ;
for(int i = n - 1; i >= 0; i --){
if(k == 0)break;
k --;
ret += arr[i];
}
cout << ret << endl;
return 0;
}
| a.cc: In function 'int main(int, const char**)':
a.cc:12:5: error: 'sort' was not declared in this scope; did you mean 'short'?
12 | sort(arr, arr + n);
| ^~~~
| short
|
s454876067 | p03658 | C | #include<iostream>
using namespace std;
void insort(int n, int a[])
{
int max;
for(int i = 0; i < n - 1; i++) {
max = i;
for(int j = i; j < n; j++)
if(a[j] > a[max])
max = j;
swap(a[i], a[max]);
}
}
int main(){
int N,K;
int l[50];
cin >> N >> K;
for(int i=0; i < N;i++){
cin >> l[i];
}
insort(N,l);
int ans = 0;
for(int i = 0; i<K;i++){
ans = ans + l[i];
}
cout << ans << endl;
} | main.c:1:9: fatal error: iostream: No such file or directory
1 | #include<iostream>
| ^~~~~~~~~~
compilation terminated.
|
s474735550 | p03658 | C++ | #include<iostream>
int selection(int A[],int n)
{
for(int i = 0;i<n;i++)
{
int minv = i;
for(int j = i;j<n;j++)
{
if(A[j]<A[minj])
{
minj = j;
}
}
int tmp = A[i];
A[i] = A[minj];
A[minj] = tmp;
}
}
int main()
{
int A[50];
int n;
int k;
std::cin >> n;
std::cin >> k;
for(int i = 0;i<n;i++)
{
std::cin >> A[i];
}
selection(A,n);
int ret= 0;
for(int i = 0;i<k;i++)
{
ret += A[n-(k+1)];
}
std::cout << ret << std::endl;
return 0;
} | a.cc: In function 'int selection(int*, int)':
a.cc:9:35: error: 'minj' was not declared in this scope; did you mean 'minv'?
9 | if(A[j]<A[minj])
| ^~~~
| minv
a.cc:15:26: error: 'minj' was not declared in this scope; did you mean 'minv'?
15 | A[i] = A[minj];
| ^~~~
| minv
a.cc:18:1: warning: no return statement in function returning non-void [-Wreturn-type]
18 | }
| ^
|
s144699377 | p03658 | Java | import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
int k = scan.nextInt();
Integer[] l = new Integer[n];
for (int i=0; i < n; i++) {
l[i] = scan.nextInt();
}
Arrays.sort(l,Collections.reverseOrder());
for (int j = 0; j < k; j++) {
int sum += l[j];
}
System.out.println(sum);
}
} | Main.java:15: error: ';' expected
int sum += l[j];
^
Main.java:15: error: not a statement
int sum += l[j];
^
2 errors
|
s555563835 | p03658 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int a,b;
cin >> a >> b ;
int c[a] = {0};
for(int i = 0;i < a;i++){
cin >> c[i];
}
sort(c.begin(), c.end());
int sum = 0;
for(int i=a-1;i>=a-b;i--){
sum+=c[i];
}
cout << sum << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:12:12: error: request for member 'begin' in 'c', which is of non-class type 'int [a]'
12 | sort(c.begin(), c.end());
| ^~~~~
a.cc:12:23: error: request for member 'end' in 'c', which is of non-class type 'int [a]'
12 | sort(c.begin(), c.end());
| ^~~
|
s809624165 | p03658 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int a,b;
cin >> a >> b ;
int c[a] = {0};
for(int i = 0;i < a;i++){
cin >> c[i];
}
sort(c.end(), c.begin());
int sum = 0;
for(int i=a-1;i>=a-b;i--){
sum+=c[i];
}
cout << sum << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:12:12: error: request for member 'end' in 'c', which is of non-class type 'int [a]'
12 | sort(c.end(), c.begin());
| ^~~
a.cc:12:21: error: request for member 'begin' in 'c', which is of non-class type 'int [a]'
12 | sort(c.end(), c.begin());
| ^~~~~
|
s429398082 | p03658 | C++ | #inclide<iostream>
#inclide<algorithm>
using namespace std;
int main(){
int n,k,ans;
cin>>n>>k;
int l[50];
for(int i=0;i<n;i++){
cin>>l[i];
}
sort(l,l+n);
for(int j=n-k;j<n;j++){
ans=ans+l[j];
}
cout<<ans<<endl;
return 0;
} | a.cc:1:2: error: invalid preprocessing directive #inclide; did you mean #include?
1 | #inclide<iostream>
| ^~~~~~~
| include
a.cc:2:2: error: invalid preprocessing directive #inclide; did you mean #include?
2 | #inclide<algorithm>
| ^~~~~~~
| include
a.cc: In function 'int main()':
a.cc:7:1: error: 'cin' was not declared in this scope
7 | cin>>n>>k;
| ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
+++ |+#include <iostream>
1 | #inclide<iostream>
a.cc:12:1: error: 'sort' was not declared in this scope; did you mean 'short'?
12 | sort(l,l+n);
| ^~~~
| short
a.cc:16:1: error: 'cout' was not declared in this scope
16 | cout<<ans<<endl;
| ^~~~
a.cc:16:1: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:16:12: error: 'endl' was not declared in this scope
16 | cout<<ans<<endl;
| ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
+++ |+#include <ostream>
1 | #inclide<iostream>
|
s818004063 | p03658 | Java | import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
public class Main {
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
ArrayList ar = new ArrayList();
for(int i = 0; i < n; i++){
ar.add(sc.nextInt());
}
Collections.sort(ar);
int ret = 0;
for (int i = 0; i < k ; i++){
ret += ar.get(ar.size()-i);
}
System.out.println(ret);
}
}
| Main.java:17: error: bad operand types for binary operator '+'
ret += ar.get(ar.size()-i);
^
first type: int
second type: Object
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
|
s062867695 | p03658 | C | #include<stdio.h>
#include<stdlib.h>
/* ソート関数 */
/*int compare_int( const void * a , const void * b ) {
// 引数はvoid*型と規定されているのでint型にcastする
if( *( int * )a < *( int * )b ) {
return -1;
}
else
if( *( int * )a == *( int * )b ) {
return 0;
}
return 1;
}
*/
int main(void){
int n;
int k,i,j;
int l[50];
int max = 0;
scanf("%d %d",&n,&k);
for(i = 0;i<n;i++) scanf("%d",&l[i]);
//qsort(l,50,sizeof(l),compare_int);
for(int i = 1;i<n;i++){
int j = i;
while(j>=1 && l[j-1] > l[j]){
int temp = l[j];
l[j] = l[j-1];
l[j-1] = temp;
j--;
}
}
for(j = n:j>n-k-1;j--){
max+=l[j];
}
printf("%d\n",max);
return 0;
} | main.c: In function 'main':
main.c:38:18: error: expected ';' before ':' token
38 | for(j = n:j>n-k-1;j--){
| ^
| ;
main.c:38:30: error: expected ';' before ')' token
38 | for(j = n:j>n-k-1;j--){
| ^
| ;
|
s460375073 | p03658 | C | #include<stdio.h>
#include<stdlib.h>
/* ソート関数 */
int compare_int( const void * a , const void * b ) {
/* 引数はvoid*型と規定されているのでint型にcastする */
if( *( int * )a < *( int * )b ) {
return -1;
}
else
if( *( int * )a == *( int * )b ) {
return 0;
}
return 1;
}
int main(void){
int n;
int k,i,j;
int l[50];
int max = 0;
scanf("%d %d",&n,&k);
for(i = 0;i<n;i++) scanf("%d",&l[i]);
qsort(l,50,sizeof(l),compare_int);
/*for(int i = 1;i<n;i++){
int j = i;
while(j>=1 && l[j-1] > l[j]){
int temp = l[j];
l[j] = l[j-1];
l[j-1] = temp;
j--;
}
}*/
for(j = n:j>n-k-1;j--){
max+=l[j];
}
printf("%d\n",max);
return 0;
} | main.c: In function 'main':
main.c:38:18: error: expected ';' before ':' token
38 | for(j = n:j>n-k-1;j--){
| ^
| ;
main.c:38:30: error: expected ';' before ')' token
38 | for(j = n:j>n-k-1;j--){
| ^
| ;
|
s524982150 | p03658 | C++ | #include <iostream>
#include <vector>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
vector<int> l(n, 0);
for (int i = 0; i < n; i++) {
cin >> l[i];
}
sort(l.begin(), l.end(), greater<int>());
int sum = 0;
for (int i = 0; i < k; i++) {
sum += l[i];
}
cout << sum << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:14:9: error: 'sort' was not declared in this scope; did you mean 'short'?
14 | sort(l.begin(), l.end(), greater<int>());
| ^~~~
| short
|
s537937998 | p03658 | C++ | #include <iostream>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
int l[N];
for (int i = 0; i < N; i++) {
cin >> l[i];
}
sort(l, l + N);
int ans = 0;
for (int i = 0; i < K; i++) {
ans += l[N - 1 -i];
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:11:5: error: 'sort' was not declared in this scope; did you mean 'short'?
11 | sort(l, l + N);
| ^~~~
| short
|
s824035437 | p03658 | C++ | #include <iostream>
#include <algorithm>
using namespace std;
bool cmp(int x,int y)
{
return (x>y);
}
int main()
{
int k,n,sum,tab[100];
cin>>n>>k;
for (i=1;i<=n;i++)
cin>>tab[i];
sort(tab+1,tab+n+1,cmp);
sum=0;
for (i=1;i<=k;i++)
sum+=tab[i];
cout<<sum<<"\n";
} | a.cc: In function 'int main()':
a.cc:14:14: error: 'i' was not declared in this scope
14 | for (i=1;i<=n;i++)
| ^
a.cc:18:14: error: 'i' was not declared in this scope
18 | for (i=1;i<=k;i++)
| ^
|
s417103764 | p03658 | C++ | #include <iostream>
#include <aglorithm>
using namespace std;
bool cmp(int x,int y)
{
return (x>y);
}
int main()
{
int k,n,sum,tab[100];
cin>>n>>k;
for (i=1;i<=n;i++)
cin>>tab[i];
sort(tab+1,tab+n+1,cmp);
sum=0;
for (i=1;i<=k;i++)
sum+=tab[i];
cout<<sum<<"\n";
} | a.cc:2:10: fatal error: aglorithm: No such file or directory
2 | #include <aglorithm>
| ^~~~~~~~~~~
compilation terminated.
|
s509594635 | p03658 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
vector<int> Ls(N);
for (auto & e : Ls) cin >> e;
sort(Ls.begin(), Ls.end());
int cum = accumulate(Ls.rbegin(), Ls.rbegin() + K, 0);
cout << cum << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:12:15: error: 'accumulate' was not declared in this scope
12 | int cum = accumulate(Ls.rbegin(), Ls.rbegin() + K, 0);
| ^~~~~~~~~~
|
s317044677 | p03658 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
int n,i,sum=0;
cin>>n;
int a[n];
for(i=0;i<n;i++)
cin>>a[i];
sort(a,a+n);
for(i=n-1;i>=n-k;i--)
sum+=a[i];
cout<<sum;
} | a.cc: In function 'int main()':
a.cc:10:16: error: 'k' was not declared in this scope
10 | for(i=n-1;i>=n-k;i--)
| ^
|
s121184143 | p03658 | C++ | #include <stdio.h>
#include <stdlib.h>
#define IN(a) int a;scanf("%d",&a);
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define STRS(i,str) for(int i=0;(str)[i];i++)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX3(a,b,c) ((a)>(b)?(a)>(c)?(a):(c):(b)>(c)?(b):(c))
#define MIN3(a,b,c) ((a)<(b)?(a)<(c)?(a):(c):(b)<(c)?(b):(c))
#define RANGE(a,b) ((a)>(b)?(a)-(b):(b)-(a))
#define RANGE3(a,b,c) ((a)>(b)?(b)>(c)?(a)-(c):(c)>(a)?(c)-(b):(a)-(b):(b)>(c)?(c)>(a)?(b)-(a):(b)-(c):(c)-(a))
#define MAXI(a,b) if(a<b)a=b;
#define MINI(a,b) if(a>b)a=b;
int main(void){
int n, k;
int l[60], size = 0;
int ans = 0;
scanf("%d%d", &n, &k);
REP(i, n) l[i] = 0;
scanf("%d", l);
FOR(i, 1, n){
scanf("%d", l + i);
int j = i;
while(l[j] > l[(j - 1)/2]){
int tmp = l[j];
l[j] = l[(j - 1)/2];
l[(j - 1)/2] = tmp;
j = (j - 1)/2;
}
}
REP(i, k){
ans += l[0];
l[0] = l[n - i - 1];
int j = 0;
while(l[j] < max(l[j * 2 + 1], l[j * 2 + 2])){
int tmp = l[j];
l[j] = max(l[j * 2 + 1], l[j * 2 + 2]);
(l[j * 2 + 1] > l[j * 2 + 2] ? l[j * 2 + 1] : l[j * 2 + 2]) = tmp;
j = j * 2 + 1 + (l[j * 2 + 1] < l[j * 2 + 2]);
}
}
printf("%d\n", ans);
return 0;
} | a.cc: In function 'int main()':
a.cc:42:30: error: 'max' was not declared in this scope
42 | while(l[j] < max(l[j * 2 + 1], l[j * 2 + 2])){
| ^~~
|
s631912541 | p03658 | C++ | #include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
int n.k,l[i],ans=0;
cin>>n>>k;
for(int i=0;i<n;i++){
cin>>l[i];
}
sort(l,l+n);
for(int j=0;j<n-k+1;i++){
ans+=l[i];
}
cout<<ans<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:6:14: error: expected initializer before '.' token
6 | int n.k,l[i],ans=0;
| ^
a.cc:7:14: error: 'n' was not declared in this scope
7 | cin>>n>>k;
| ^
a.cc:7:17: error: 'k' was not declared in this scope
7 | cin>>n>>k;
| ^
a.cc:9:30: error: 'l' was not declared in this scope
9 | cin>>l[i];
| ^
a.cc:11:22: error: 'l' was not declared in this scope
11 | sort(l,l+n);
| ^
a.cc:12:37: error: 'i' was not declared in this scope
12 | for(int j=0;j<n-k+1;i++){
| ^
a.cc:13:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
13 | ans+=l[i];
| ^~~
| abs
a.cc:15:23: error: 'ans' was not declared in this scope; did you mean 'abs'?
15 | cout<<ans<<endl;
| ^~~
| abs
|
s146495852 | p03658 | C | #include<stdio.h>
int main(void)
{
int K,N,hebi,i,I[51];
scanf("%d %d",&N,&K);
for(i=1; i<=N; i++){
scanf("%d",I[i]);
}
for(i=1; i<=K; i++){
hebi=hebi+I[] | main.c: In function 'main':
main.c:12:17: error: expected expression before ']' token
12 | hebi=hebi+I[]
| ^
main.c:12:17: error: expected declaration or statement at end of input
main.c:12:17: error: expected declaration or statement at end of input
|
s565318905 | p03658 | C++ | #include <iostream>
#include <map>
using namespace std;
int main(){
int n,k,l,counter=0,ans=0;
map<int,int> mp;
cin >> n >> k;
for(int i = 0; i < n; i++){
cin >> l;
mp[-1*l]=l;
}
for(auto itr=mp.begin(),itr!=mp.end(),itr++){
ans+=itr->second;
k++;
if(counter==k){
break;
}
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:13:30: error: expected ';' before '!=' token
13 | for(auto itr=mp.begin(),itr!=mp.end(),itr++){
| ^~
| ;
a.cc:13:30: error: expected primary-expression before '!=' token
13 | for(auto itr=mp.begin(),itr!=mp.end(),itr++){
| ^~
a.cc:13:46: error: expected ';' before ')' token
13 | for(auto itr=mp.begin(),itr!=mp.end(),itr++){
| ^
| ;
|
s375740437 | p03658 | C++ | //#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<cmath>
#define lowbit(x) ((x)&(-x))
#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a>b?b:a)
#define INF 0x3f3f3f3f
#define sz size()
#define pb push_back
#define ph push
#define mem(x, y) memset(x, y, sizeof(x));
#define mem0(x) mem(x,0)
#define mem1(x) mem(x,-1)
#define memINF(x) mem(x,INF)
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
using namespace std;
typedef long long ll;
int const Max_N = 1e6+5;
ll a[Max_N];
ll sum[Max_N];
int main()
{
int N;
cin >> N;
rep(i,1,N+1)
{
cin >> a[i];
sum[i] += sum[i-1] + a[i];
}
ll ans = 1e18;
rep(i,1,N)
{
// cout << sum[i] << endl;
// cout << sum[N] - 2*sum[i] << endl;
ans = min(ans,abs(sum[N] - 2*sum[i]));
}
cout << ans << endl;
return 0;
} | a.cc:30:1: error: extended character is not valid in an identifier
30 |
| ^
a.cc:43:1: error: extended character is not valid in an identifier
43 |
| ^
a.cc:44:1: error: extended character is not valid in an identifier
44 |
| ^
a.cc:30:1: error: '\U000000a0' does not name a type
30 |
| ^
a.cc:32:6: error: 'Max_N' was not declared in this scope; did you mean 'Max'?
32 | ll a[Max_N];
| ^~~~~
| Max
a.cc:33:8: error: 'Max_N' was not declared in this scope; did you mean 'Max'?
33 | ll sum[Max_N];
| ^~~~~
| Max
a.cc:33:14: error: expected initializer before '\U0000ff1b'
33 | ll sum[Max_N];
| ^~
|
s529296510 | p03658 | C++ | //#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<cmath>
#define lowbit(x) ((x)&(-x))
#define Max(a,b) (a>b?a:b)
#define Min(a,b) (a>b?b:a)
#define INF 0x3f3f3f3f
#define sz size()
#define pb push_back
#define ph push
#define mem(x, y) memset(x, y, sizeof(x));
#define mem0(x) mem(x,0)
#define mem1(x) mem(x,-1)
#define memINF(x) mem(x,INF)
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=a;i>(b);--i)
using namespace std;
typedef long long ll;
int const Max_N = 1e6+5;
ll a[Max_N];
ll sum[Max_N] = {0};
int main()
{
int N;
cin >> N;
rep(i,1,N+1)
{
cin >> a[i];
sum[i] += sum[i-1] + a[i];
}
ll ans = 1e18;
rep(i,1,N)
{
// cout << sum[i] << endl;
// cout << sum[N] - 2*sum[i] << endl;
ans = min(ans,abs(sum[N] - 2*sum[i]));
}
cout << ans << endl;
return 0;
} | a.cc:30:1: error: extended character is not valid in an identifier
30 |
| ^
a.cc:43:1: error: extended character is not valid in an identifier
43 |
| ^
a.cc:44:1: error: extended character is not valid in an identifier
44 |
| ^
a.cc:30:1: error: '\U000000a0' does not name a type
30 |
| ^
a.cc:32:6: error: 'Max_N' was not declared in this scope; did you mean 'Max'?
32 | ll a[Max_N];
| ^~~~~
| Max
a.cc:33:8: error: 'Max_N' was not declared in this scope; did you mean 'Max'?
33 | ll sum[Max_N] = {0};
| ^~~~~
| Max
a.cc: In function 'int main()':
a.cc:40:24: error: 'a' was not declared in this scope
40 | cin >> a[i];
| ^
a.cc:41:17: error: 'sum' was not declared in this scope
41 | sum[i] += sum[i-1] + a[i];
| ^~~
a.cc:43:1: error: '\U000000a0' was not declared in this scope
43 |
| ^
a.cc:50:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
50 | ans = min(ans,abs(sum[N] - 2*sum[i]));
| ^~~
| abs
a.cc:50:35: error: 'sum' was not declared in this scope
50 | ans = min(ans,abs(sum[N] - 2*sum[i]));
| ^~~
a.cc:52:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
52 | cout << ans << endl;
| ^~~
| abs
|
s672165624 | p03658 | C++ |
#include <iostream>
#include <vector>
#include <algorithm> //ソート用
using namespace std;
int main(void){
int n,k;
cin >> n >> k;
vector<int> l(n); //vectorの大きさをnに設定
for(int i = 0; i < n; i++){
cin >> l[i];
}
// for(int &val : l){
// cin >> val;
// }
sort(l.begin(),l.end()); //C++ではソート用の関数が用意されていることが多いため、ソート関数を実装する必要はない
int ans = 0;
for(int i = 0; i < k; i++){
ans += 1[n-1-i];
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:23:17: error: invalid types 'int[int]' for array subscript
23 | ans += 1[n-1-i];
| ^
|
s659236569 | p03658 | C++ |
#include <iostream>
#include <vector>
#include <algorithm> //ソート用
using namespace std;
int main(void){
int n,k;
cin >> n >> k;
vector<int> l(n); //vectorの大きさをnに設定
for(int i = 0; i < n; i++){
cin >> l[i];
}
sort(l.begin(),l.end()); //C++ではソート用の関数が用意されていることが多いため、ソート関数を実装する必要はない
int ans = 0;
for(int i = 0; i < k; i++){
ans += 1[n-1-i];
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:21:17: error: invalid types 'int[int]' for array subscript
21 | ans += 1[n-1-i];
| ^
|
s965845574 | p03658 | C++ |
#include <iostream>
#include <vector>
#include <algorithm> //ソート用
using namespace std;
int main(void){
int n,k;
cin >> n >> k;
vector<int> l(n); //vectorの大きさをnに設定
// for(int i = 0; i < n; i++){
// cin >> l[i];
// }
for(int &val : l){
cin >> val;
}
sort(l.begin(),l.end()); //C++ではソート用の関数が用意されていることが多いため、ソート関数を実装する必要はない
int ans = 0;
for(int i = 0; i < k; i++){
ans += 1[n-1-i];
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:23:17: error: invalid types 'int[int]' for array subscript
23 | ans += 1[n-1-i];
| ^
|
s713287299 | p03658 | C++ | #include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
typedef long long int ll;
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EREP(i,n) for (int i=1;i<=(n);i++)
#define ALL(a) (a).begin(),(a).end()
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X << ":" <<X<<" " ;
#define TF(f) f ? cout<<"true " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const int MOD = 1000000007;
const int INF = 2000000000;
ll ans=0,id;
int N,M;
ll A,B,C,W;
int a[100010];
bool f=false;
ll sum=0;
string S;
int main(){
ios_base::sync_with_stdio(false);
cin>>N>>M;
REP(i,N)cin>>a[i];
sort(a,a+N);
REP(i,K){
ans+=a[N-i-1];
}
cout<<ans;
return 0;
}
| a.cc: In function 'int main()':
a.cc:43:11: error: 'K' was not declared in this scope
43 | REP(i,K){
| ^
a.cc:14:34: note: in definition of macro 'REP'
14 | #define REP(i,n) for (int i=0;i<(n);i++)
| ^
|
s034432759 | p03658 | C++ | #include<cstdio>
int main(){
int max = 0;
int n, k;
int l[50];
scanf("%d%d,&n,&k);
for(int i = 0; i < n; i++){
scanf("%d", &l[i]);
if(max < l[i]){
max = l[i];
}
}
int sum = 0, ans = 0;
sum += max;
for(i = 0; i < n; i++){
for(int j = 0; j < n; j++){
if(n * max > ans && sum + l[i] + l[j] > ans){
ans = sum + l[i] + l[j];
}
}
}
printf("%d",ans);
return 0;
} | a.cc:7:15: warning: missing terminating " character
7 | scanf("%d%d,&n,&k);
| ^
a.cc:7:15: error: missing terminating " character
7 | scanf("%d%d,&n,&k);
| ^~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:9:9: error: expected primary-expression before 'for'
9 | for(int i = 0; i < n; i++){
| ^~~
a.cc:9:24: error: 'i' was not declared in this scope
9 | for(int i = 0; i < n; i++){
| ^
|
s745153978 | p03658 | C++ | #include <stdio.h>
int main(void)
{
int i,j,cng,ans;
int N,K;
int l[50];
scanf("%d %d",&N,&K);
for(i=0;i<N;i++){
scanf("%d",&l[N]);
}
for(i=0;i<N;i++){
for(j=0;j<N;i++){
if(l[i]< l[j]){
cng =l[i];
l[i] = l[j];
l[j] = cng;
}
}
}
ans =0;
for(i=0;i<K;i++){
ans = ans +l[K];
}
printf("%d",ans);
return 0;
| a.cc: In function 'int main()':
a.cc:34:18: error: expected '}' at end of input
34 | return 0;
| ^
a.cc:4:1: note: to match this '{'
4 | {
| ^
|
s169361656 | p03658 | C++ | #include <stdio.h>
int main(void)
{
int i,j,cng,ans;
int N,K;
int l[50];
scanf("%d %d",&N,&K);
for(i=0;i<N;i++){
scanf("%d",&l[N]);
}
for(i=0;i<N;i++){
for(j=0;j<N;i++){
if(l[i]< l[j]){
cng =l[i];
l[i] = l[j];
l[j] = cng;
}
}
}
ans =0;
for(i=0;i<K;i++){
ans = ans +l[K];
}
printf("%d",ans);
return 0;
| a.cc: In function 'int main()':
a.cc:34:18: error: expected '}' at end of input
34 | return 0;
| ^
a.cc:4:1: note: to match this '{'
4 | {
| ^
|
s310480447 | p03658 | C | #include<stdio.h>
int N, K;
int Snake[1000000];
int main(void){
int i, j, c, sum;
scanf("%d %d", &N, &K);
for(i = 0; i < N; i++){
scanf("%d", &Snake[i]);
}
for( i = 0; i < N-1; i++){
for(j = i + 1; j < N; j++){
if(Snake[i] <= Snake[j] ){
c = Snake[j];
Snake[i] = Snake[j];
Snake[j] = c;
}
}}
sum = 0;
for(i = 0; i < K; i++){
sum += Snake[i];
}
printf("%d". sum);
return 0;
} | main.c: In function 'main':
main.c:28:12: error: request for member 'sum' in something not a structure or union
28 | printf("%d". sum);
| ^
|
s150057297 | p03658 | C | #include<stdio.h>
int N, K;
int Snake[100000];
int main(void){
int i, j, c, sum;
scanf("%d %d", &N, &K);
for(i = 0; i < N; i++){
scanf("%d", &Snake[i];
}
for( i = 0; i < N-1; i++){
for(j = i + 1; j < N; j++){
if(Snake[i] <= Snake[j] ){ c = Snake[j]; Snake[i] = Snake[j]; Snake[j] = c;
}
}}
sum = 0;
for(i = 0; i < K; i++){
sum += Snake[i];
}
return 0;
}
| main.c: In function 'main':
main.c:10:22: error: expected ')' before ';' token
10 | scanf("%d", &Snake[i];
| ~ ^
| )
main.c:10:23: error: expected ';' before '}' token
10 | scanf("%d", &Snake[i];
| ^
| ;
11 | }
| ~
|
s463406186 | p03658 | C++ | #include <bits/stdc++.h>
using namespace std;
int arr[100];
int main() {
int n,k,ans=0;
cin>>n>>k;
for(int i=0;i<n;++i) cin>>a[i];
sort(a,a+n);
reverse(a,a+n);
for(int i=0;i<k;++i) ans+=a[i];
cout<<ans<<'\n';
} | a.cc: In function 'int main()':
a.cc:12:35: error: 'a' was not declared in this scope
12 | for(int i=0;i<n;++i) cin>>a[i];
| ^
a.cc:14:14: error: 'a' was not declared in this scope
14 | sort(a,a+n);
| ^
|
s678797391 | p03658 | C | #include<stdio.h>
#include<algorithm>
using namespace std;
int a[100];
int main()
{
int N,K;
while(~scanf("%d%d",&N,&K))
{
int sum=0;
for(int i=1;i<=N;i++)
{
scanf("%d",&a[i]);
}
sort(a+1,a+N+1);
for(int i=N-K+1;i<=N;i++)
{
sum=sum+a[i];
}
printf("%d\n",sum);
}
return 0;
}
| main.c:2:9: fatal error: algorithm: No such file or directory
2 | #include<algorithm>
| ^~~~~~~~~~~
compilation terminated.
|
s098383273 | p03658 | C++ | #include<cstdio>
#include<bits/stdc++.h>
#include<cstring>
#include<algorithm>
#include<iostream>
bool cmp(int a,int b)
{
return a>b;
}
int main()
{
int a[55];
int x,y;
while(scanf("%d%d",&x,&y)!=EOF)
{ memset(a,0,sizeof(a));
for(int i=0;i<x;i++)
scanf("%d",&a[i]);
sort(a,a+x,cmp);
long long sum=0;
for(int q=0;q<y;q++)
sum=sum+a[q];
printf("%lld\n",sum);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:20:10: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
20 | sort(a,a+x,cmp);
| ^~~~
| std::sort
In file included from /usr/include/c++/14/algorithm:86,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:2:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
| ^~~~
|
s421164496 | p03658 | C++ | #include <algorithm>
#include <iostream>
using namespace std;
int main(){
int N,a,l[50],yan,b;
cin>>N>>a;
for(int i=0;i<N;i++){
cin>>l[i];
}
for(int j=0;j<N;j++){
for(int k=i+1;k<N;k++){
if(l[j]>l[k]){
yan=l[j];
l[j]=l[k];
l[k]=yan;
}
}
}
for(int m=0;m<a;m++){
b+=l[m]
}
cout<<b<<endl;
} | a.cc: In function 'int main()':
a.cc:12:11: error: 'i' was not declared in this scope
12 | for(int k=i+1;k<N;k++){
| ^
a.cc:21:8: error: expected ';' before '}' token
21 | b+=l[m]
| ^
| ;
22 | }
| ~
|
s166534635 | p03658 | C++ | #include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
int main(int argc, char *argv[])
{
int n,k;
while(scanf("%d %d",&n,&k)!=EOF)
{
int a[52],s=0,i,j;
for(i=0;i<n;i++)
scanf("%d",&a[i]);
sort(a,a+n);
for(i=n-1,j=0;i>=0;i--,j++)
{
s=s+a[i];
if(j==(k-1))break;
}
printf("%d\n",s);
}
return 0;
}
| a.cc: In function 'int main(int, char**)':
a.cc:13:17: error: 'sort' was not declared in this scope; did you mean 'short'?
13 | sort(a,a+n);
| ^~~~
| short
|
s633895822 | p03658 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
vector<int> L;
L.reserve(N);
int data;
for (int n = 0; n < N; n++) {
cin >> data;
L.push_back(data);
}
sort(L.begin(), L.end());
auto itr = L.rbegin();
int sum = 0;
for (int n = 0; n < K; n++) {
sum += *itr;
itr++;
}
cout << sum << endl;
return 0;
| a.cc: In function 'int main()':
a.cc:31:14: error: expected '}' at end of input
31 | return 0;
| ^
a.cc:7:12: note: to match this '{'
7 | int main() {
| ^
|
s141772902 | p03658 | C++ | #include <stdio.h>
#include <iostream>
#include <string>
using namespace std;
int main(void){
int N, K;
int ans=0;
cin >> N >> K;
int l[N];
for(int i=0; i<N; i++){
cin >> l[i];
}
sort(l, l+N);
for(int i=0; i<K; i++){
ans += l[N-i-1];
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:15:9: error: 'sort' was not declared in this scope; did you mean 'short'?
15 | sort(l, l+N);
| ^~~~
| short
|
s785591303 | p03658 | C++ | #include<bits/stdc++.h>
using namespace std;
int a[51];
int main()
{
int n,k;
cin>>n>>k;
for(int i=0;i<n;i++)
{
cin>>a[i];
}
int sum=0;
sort(a,a+n);
for(int i=n-1;i>=n-k;i--)
{
sum+=a[i];
}
cout>>sum;
return 0;
} | a.cc: In function 'int main()':
a.cc:18:13: error: no match for 'operator>>' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and 'int')
18 | cout>>sum;
| ~~~~^~~~~
| | |
| | int
| std::ostream {aka std::basic_ostream<char>}
a.cc:18:13: note: candidate: 'operator>>(int, int)' (built-in)
18 | cout>>sum;
| ~~~~^~~~~
a.cc:18:13: note: no known conversion for argument 1 from 'std::ostream' {aka 'std::basic_ostream<char>'} to 'int'
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41,
from a.cc:1:
/usr/include/c++/14/cstddef:131:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator>>(byte, _IntegerType)'
131 | operator>>(byte __b, _IntegerType __shift) noexcept
| ^~~~~~~~
/usr/include/c++/14/cstddef:131:5: note: template argument deduction/substitution failed:
a.cc:18:9: note: cannot convert 'std::cout' (type 'std::ostream' {aka 'std::basic_ostream<char>'}) to type 'std::byte'
18 | cout>>sum;
| ^~~~
In file included from /usr/include/c++/14/string:55,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/basic_string.tcc:835:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
835 | operator>>(basic_istream<_CharT, _Traits>& __in,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.tcc:835:5: note: template argument deduction/substitution failed:
a.cc:18:15: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
18 | cout>>sum;
| ^~~
/usr/include/c++/14/bitset:1597:5: note: candidate: 'template<class _CharT, class _Traits, long unsigned int _Nb> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, bitset<_Nb>&)'
1597 | operator>>(std::basic_istream<_CharT, _Traits>& __is, bitset<_Nb>& __x)
| ^~~~~~~~
/usr/include/c++/14/bitset:1597:5: note: template argument deduction/substitution failed:
a.cc:18:15: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
18 | cout>>sum;
| ^~~
In file included from /usr/include/c++/14/istream:1109,
from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/bits/istream.tcc:978:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _CharT&)'
978 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT& __c)
| ^~~~~~~~
/usr/include/c++/14/bits/istream.tcc:978:5: note: template argument deduction/substitution failed:
a.cc:18:15: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
18 | cout>>sum;
| ^~~
/usr/include/c++/14/istream:849:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, unsigned char&)'
849 | operator>>(basic_istream<char, _Traits>& __in, unsigned char& __c)
| ^~~~~~~~
/usr/include/c++/14/istream:849:5: note: template argument deduction/substitution failed:
a.cc:18:15: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>'
18 | cout>>sum;
| ^~~
/usr/include/c++/14/istream:854:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, signed char&)'
854 | operator>>(basic_istream<char, _Traits>& __in, signed char& __c)
| ^~~~~~~~
/usr/include/c++/14/istream:854:5: note: template argument deduction/substitution failed:
a.cc:18:15: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>'
18 | cout>>sum;
| ^~~
/usr/include/c++/14/istream:896:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _CharT*)'
896 | operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s)
| ^~~~~~~~
/usr/include/c++/14/istream:896:5: note: template argument deduction/substitution failed:
a.cc:18:15: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
18 | cout>>sum;
| ^~~
/usr/include/c++/14/istream:939:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, unsigned char*)'
939 | operator>>(basic_istream<char, _Traits>& __in, unsigned char* __s)
| ^~~~~~~~
/usr/include/c++/14/istream:939:5: note: template argument deduction/substitution failed:
a.cc:18:15: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>'
18 | cout>>sum;
| ^~~
/usr/include/c++/14/istream:945:5: note: candidate: 'template<class _Traits> std::basic_istream<char, _Traits>& std::operator>>(basic_istream<char, _Traits>&, signed char*)'
945 | operator>>(basic_istream<char, _Traits>& __in, signed char* __s)
| ^~~~~~~~
/usr/include/c++/14/istream:945:5: note: template argument deduction/substitution failed:
a.cc:18:15: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<char, _Traits>'
18 | cout>>sum;
| ^~~
/usr/include/c++/14/istream:1099:5: note: candidate: 'template<class _Istream, class _Tp> _Istream&& std::operator>>(_Istream&&, _Tp&&)'
1099 | operator>>(_Istream&& __is, _Tp&& __x)
| ^~~~~~~~
/usr/include/c++/14/istream:1099:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/istream: In substitution of 'template<class _Istream, class _Tp> _Istream&& std::operator>>(_Istream&&, _Tp&&) [with _Istream = std::basic_ostream<char>&; _Tp = int&]':
a.cc:18:8: required from here
18 | cout>>sum;
| ^~~
/usr/include/c++/14/istream:1099:5: error: no type named 'type' in 'struct std::enable_if<false, void>'
1099 | operator>>(_Istream&& __is, _Tp&& __x)
| ^~~~~~~~
/usr/include/c++/14/complex:509:5: note: candidate: 'template<class _Tp, class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, complex<_Tp>&)'
509 | operator>>(basic_istream<_CharT, _Traits>& __is, complex<_Tp>& __x)
| ^~~~~~~~
/usr/include/c++/14/complex:509:5: note: template argument deduction/substitution failed:
a.cc:18:15: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
18 | cout>>sum;
| ^~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:143:
/usr/include/c++/14/iomanip:76:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _Resetiosflags)'
76 | operator>>(basic_istream<_CharT, _Traits>& __is, _Resetiosflags __f)
| ^~~~~~~~
/usr/include/c++/14/iomanip:76:5: note: template argument deduction/substitution failed:
a.cc:18:15: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
18 | cout>>sum;
| ^~~
/usr/include/c++/14/iomanip:106:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _Setiosflags)'
106 | operator>>(basic_istream<_CharT, _Traits>& __is, _Setiosflags __f)
| ^~~~~~~~
/usr/include/c++/14/iomanip:106:5: note: template argument deduction/substitution failed:
a.cc:18:15: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
18 | cout>>sum;
| ^~~
/usr/include/c++/14/iomanip:137:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _Setbase)'
137 | operator>>(basic_istream<_CharT, _Traits>& __is, _Setbase __f)
| ^~~~~~~~
/usr/include/c++/14/iomanip:137:5: note: template argument deduction/substitution failed:
a.cc:18:15: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
18 | cout>>sum;
| ^~~
/usr/include/c++/14/iomanip:177:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _Setfill<_CharT>)'
177 | operator>>(basic_istream<_CharT, _Traits>& __is, _Setfill<_CharT> __f)
| ^~~~~~~~
/usr/include/c++/14/iomanip:177:5: note: template argument deduction/substitution failed:
a.cc:18:15: note: 'std::ostream' {aka 'std::basic_ostream<char>'} is not derived from 'std::basic_istream<_CharT, _Traits>'
18 | cout>>sum;
| ^~~
/usr/include/c++/14/iomanip:207:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_istream<_CharT, _Traits>& std::operator>>(basic_istream<_CharT, _Traits>&, _Setprecision)'
207 | operator>>(basic_istream<_CharT, _Traits>& __is, _Setprecision __f)
| ^~~~~~~~
/usr/include/c++/14/iomanip:207:5: note: template argument deduction/substitution failed:
a.cc:18:15: note: 'std::ostream' {ak |
s845123084 | p03658 | C++ |
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
int N, K;
int ans = 0;
vector<int> L;
vector<int> M;
cin >> N >> K;
for (int i = 0; i < N; ++i) {
int n; cin >> n;
L.push_back(n);
}
for (int i = 0; i < K; ++i) {
auto itr = max_element(L.begin(), L.end());
M[i] = *itr;
L.erase(itr);
ans += *itr;
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:30:20: error: 'max_element' was not declared in this scope
30 | auto itr = max_element(L.begin(), L.end());
| ^~~~~~~~~~~
|
s604766628 | p03658 | Java | public class Main {
private final static Scanner sc = new Scanner(System.in);
/**
* 本処理を実行します。
*/
public static void execute() {
int n = nextInt();
int k = nextInt();
Integer[] l = nextInts(n);
Arrays.sort(l, Comparator.reverseOrder());
int length = 0;
for (int i = 0;i < k; i++) {
length += l[i];
}
out(length);
}
/**
* 次の標準入力をintで受け取ります。
* @return 標準入力値(int)
*/
public static int nextInt() {
return sc.nextInt();
}
/**
* 次の標準入力をStringで受け取ります。
* @return 標準入力値(String)
*/
public static String nextString() {
return sc.next();
}
/**
* 次の標準入力を指定回数分intで受け取ります。
* @param n 取得回数
* @return 取得した標準入力値の配列(int)
*/
public static Integer[] nextInts(int n) {
Integer[] arr = new Integer[n];
for (int i = 0; i < n; i++) {
arr[i] = nextInt();
}
return arr;
}
/**
* 標準出力にオブジェクトを出力します。
* @param o 出力対象
*/
public static void out(Object o) {
System.out.println(o);
}
public static void main(String[] args) {
execute();
}
} | Main.java:3: error: cannot find symbol
private final static Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:3: error: cannot find symbol
private final static Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:13: error: cannot find symbol
Arrays.sort(l, Comparator.reverseOrder());
^
symbol: variable Arrays
location: class Main
Main.java:13: error: cannot find symbol
Arrays.sort(l, Comparator.reverseOrder());
^
symbol: variable Comparator
location: class Main
4 errors
|
s393051571 | p03658 | C++ | #include <iostream>
#include <vector>
using namespace std;
int main(void){
int N,K,l;
vector<int> ls;
cin>>N>>K;
for(int i = 0; i < N; i++){
cin>>l;
ls.push_back(l);
}
sort(ls.begin(),ls.end(),greater<int>()); //降順ソート
int sum=0;
for(int i = 0; i < K; i++){
sum+=ls[i];
}
cout<<sum<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:14:5: error: 'sort' was not declared in this scope; did you mean 'short'?
14 | sort(ls.begin(),ls.end(),greater<int>()); //降順ソート
| ^~~~
| short
|
s788504346 | p03658 | C++ | #include <iostream>
#include <vector>
using namespace std;
int main(){
int N,K;
cin >> N >> K;
std::vector<int> l(N);
std::copy_n(std::istream_iterator<int>{std::cin}, l.size(), l.begin());
sort(l.begin(),l.end());
int sum=0;
for(int i=N-K;i<N;i++){
sum+=l[i];
}
cout << sum << endl;
}
| a.cc: In function 'int main()':
a.cc:11:8: error: 'copy_n' is not a member of 'std'; did you mean 'copy'?
11 | std::copy_n(std::istream_iterator<int>{std::cin}, l.size(), l.begin());
| ^~~~~~
| copy
a.cc:11:20: error: 'istream_iterator' is not a member of 'std'
11 | std::copy_n(std::istream_iterator<int>{std::cin}, l.size(), l.begin());
| ^~~~~~~~~~~~~~~~
a.cc:3:1: note: 'std::istream_iterator' is defined in header '<iterator>'; this is probably fixable by adding '#include <iterator>'
2 | #include <vector>
+++ |+#include <iterator>
3 | using namespace std;
a.cc:11:37: error: expected primary-expression before 'int'
11 | std::copy_n(std::istream_iterator<int>{std::cin}, l.size(), l.begin());
| ^~~
a.cc:13:3: error: 'sort' was not declared in this scope; did you mean 'short'?
13 | sort(l.begin(),l.end());
| ^~~~
| short
|
s653220459 | p03658 | C++ | //2016.7.15
//ABC 067 (B)
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
int n,k, ans;
cin >> n>> k ;
vector <int> A(n);
for (int i = 0; i < n; i++) {
cin >> A[i];
}
sort(A.begin(), A.end());
while(k>0){
ans+=a[n-1];
n--;
k--;
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:20:10: error: 'a' was not declared in this scope
20 | ans+=a[n-1];
| ^
|
s522965287 | p03658 | C++ | #include <iostream>
using namespace std;
int main(){
int N, K;
int sum = 0;
int l[100];
cin >> N >> K;
for(int i = 0;i < N;i++){
cin >> l[i];
}
sort(l, l+N, std::greater<int>());
for(int i = 0;i < K;i++){
sum += l[i];
}
cout << sum << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:15:3: error: 'sort' was not declared in this scope; did you mean 'short'?
15 | sort(l, l+N, std::greater<int>());
| ^~~~
| short
|
s882494290 | p03658 | C++ | #include <iostream>
#include <algorithm>
using namespace std;
int main(){
int n,k;
int sum=0;
int l[50];
cin>>n>>k;
for(int i=0;i<n;i++){
cin>>l[i];
}
sort(l.begin(),l.end(),std::greater<int>());
for(int i=0;i<k;i++){
sum+=l[i];
}
cout<<sum<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:12:16: error: request for member 'begin' in 'l', which is of non-class type 'int [50]'
12 | sort(l.begin(),l.end(),std::greater<int>());
| ^~~~~
a.cc:12:26: error: request for member 'end' in 'l', which is of non-class type 'int [50]'
12 | sort(l.begin(),l.end(),std::greater<int>());
| ^~~
|
s158988230 | p03658 | C++ | #include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define vi vector<int>
#define vl vector<long long>
#define sz size()
#define x first
#define y second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ld long double
using namespace std;
int n, k;
int a[100];
int main() {
cin >> n >> k;
for(int i = 1;i <= n; i++) {
cin >> a[i];
}
sort(a + 1, a + n + 1);
reverse(a + 1, a + n + 1);
for(int i = 1; i <= min(n, k); i++) {
ans += a[i];
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:33:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
33 | ans += a[i];
| ^~~
| abs
a.cc:36:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
36 | cout << ans << endl;
| ^~~
| abs
|
s341547449 | p03659 | C++ | #include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using namespace std;
int main(){
int N;
cin >> N;
vector<ll> b(N+1);
rep(i,N) {
ll a;
cin >> a;
b[i+1] = b[i] + a;
}
ll ans = 1e15;
for (int i = 1; i < N; i++) {
ll x = b[i];
ll y = b[N] - x;
ans = min(ans, abs(y-x));
}
cout << ans << endl;
return 0;
}
a | a.cc:25:1: error: 'a' does not name a type
25 | a
| ^
|
s293229656 | p03659 | C++ | #include <bits/stdc++.h>
using namespace std; | /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
|
s019348199 | p03659 | C++ | #include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;
int main() {
ll N;
cin >> N;
vector<ll> a(N, 0);
rep(i, N) cin >> a[i];
ll sum = accumulate(all(a),0LL);
ll ans = =1000000000000000000LL;
ll tmp = 0;
rep(i,N){
tmp += a[i];
if(i + 1 < N) ans = min(ans, abs(sum - 2 * tmp));
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:17:14: error: expected primary-expression before '=' token
17 | ll ans = =1000000000000000000LL;
| ^
|
s730007433 | p03659 | C++ | #include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;
int main() {
ll N;
cin >> N;
vector<ll> a(N, 0);
rep(i, N) cin >> a[i];
ll sum = accumulate(all(a),0LL);
ll tmp = 0;
rep(i,N){
tmp += a[i];
if(i + 1 < N) ans = min(ans,abs(sum-2 * tmp));
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:20:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
20 | if(i + 1 < N) ans = min(ans,abs(sum-2 * tmp));
| ^~~
| abs
a.cc:22:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
22 | cout << ans << endl;
| ^~~
| abs
|
s168982580 | p03659 | C++ | /*
Contest 067
C - Splitting Pile
Rakesh Kumar --> 01/09/2020
*/
#include <bits/stdc++.h>
using ll = long long int;
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(0); std::cout.tie(0);
ll n = 0;
std::cin >> n;
std::vector<ll> v;
ll total = 0;
while (n--) {
ll e = 0;
std::cin >> e;
v.emplace_back(e);
total += e;
}
unsigned long long int min = (1e+9) + 1;
ll left_sum = v[0];
for (std::size_t i = 1; i < v.size(); ++i) {
ll right_sum = total - left_sum;
min = std::min(min, std::abs(right_sum - left_sum));
left_sum += v[i];
}
std::cout << min << std::endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:29:23: error: no matching function for call to 'min(long long unsigned int&, long long int)'
29 | min = std::min(min, std::abs(right_sum - left_sum));
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:7:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:29:23: note: deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'long long int')
29 | min = std::min(min, std::abs(right_sum - left_sum));
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:29:23: note: mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
29 | min = std::min(min, std::abs(right_sum - left_sum));
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s224850790 | p03659 | C++ | 2
10 -10 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 2
| ^
|
s626317819 | p03659 | C++ | #include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define puts(i) cout << i << endl
#define INF INT_MAX;
#define INFL LLONG_MAX;
typedef long long ll;
using namespace std;
int main(){
int k,i;
ll N,X=0,x=0,z,ans=100000000;
cin >> N;
std::vector<ll> a(N);
for(k=0;k<N;k++){
cin >> a[k];
X+=a[k];
}
for(i=0;i<N;i++){
x+=a[i];
z=abs(X-2*x);
if(i+1<n)ans=min(ans,z);
}
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:29:10: error: 'n' was not declared in this scope
29 | if(i+1<n)ans=min(ans,z);
| ^
|
s089843801 | p03659 | C++ | void solve()
{
ll n,k;
cin>>n;
ll a[n];
ll sum=0;
for(ll i=0;i<n;i++)
cin>>a[i],sum+=a[i];
ll l=0;
ll r=sum;
ll ans=1e16;
for(ll i=0;i<n-1;i++)
{
// cout<<l<<r<<" ";
l+=a[i];
r-=a[i];
ans=min(ans,abs(l-r));
}
cout<<ans;
} | a.cc: In function 'void solve()':
a.cc:3:9: error: 'll' was not declared in this scope
3 | ll n,k;
| ^~
a.cc:4:9: error: 'cin' was not declared in this scope
4 | cin>>n;
| ^~~
a.cc:4:14: error: 'n' was not declared in this scope
4 | cin>>n;
| ^
a.cc:5:11: error: expected ';' before 'a'
5 | ll a[n];
| ^~
| ;
a.cc:6:11: error: expected ';' before 'sum'
6 | ll sum=0;
| ^~~~
| ;
a.cc:7:15: error: expected ';' before 'i'
7 | for(ll i=0;i<n;i++)
| ^~
| ;
a.cc:7:20: error: 'i' was not declared in this scope
7 | for(ll i=0;i<n;i++)
| ^
a.cc:8:22: error: 'a' was not declared in this scope
8 | cin>>a[i],sum+=a[i];
| ^
a.cc:8:27: error: 'sum' was not declared in this scope
8 | cin>>a[i],sum+=a[i];
| ^~~
a.cc:9:11: error: expected ';' before 'l'
9 | ll l=0;
| ^~
| ;
a.cc:10:11: error: expected ';' before 'r'
10 | ll r=sum;
| ^~
| ;
a.cc:11:11: error: expected ';' before 'ans'
11 | ll ans=1e16;
| ^~~~
| ;
a.cc:12:15: error: expected ';' before 'i'
12 | for(ll i=0;i<n-1;i++)
| ^~
| ;
a.cc:12:20: error: 'i' was not declared in this scope
12 | for(ll i=0;i<n-1;i++)
| ^
a.cc:15:17: error: 'l' was not declared in this scope
15 | l+=a[i];
| ^
a.cc:15:20: error: 'a' was not declared in this scope
15 | l+=a[i];
| ^
a.cc:16:17: error: 'r' was not declared in this scope
16 | r-=a[i];
| ^
a.cc:17:17: error: 'ans' was not declared in this scope
17 | ans=min(ans,abs(l-r));
| ^~~
a.cc:17:29: error: 'abs' was not declared in this scope
17 | ans=min(ans,abs(l-r));
| ^~~
a.cc:17:21: error: 'min' was not declared in this scope
17 | ans=min(ans,abs(l-r));
| ^~~
a.cc:19:9: error: 'cout' was not declared in this scope
19 | cout<<ans;
| ^~~~
a.cc:19:15: error: 'ans' was not declared in this scope
19 | cout<<ans;
| ^~~
|
s203984049 | p03659 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll n, ans=0;
cin >> n;
vl a(n);
rep(i, n) {
cin >> a[i];
if(i==0) x+=a[i];
else y+=a[i];
}
ans = abs(x-y);
rep2(i, n-2) {
x += a[i];
y -= a[i];
chmin(ans, abs(x-y));
}
cout << ans << newl;
return 0;
} | a.cc: In function 'int main()':
a.cc:37:14: error: 'x' was not declared in this scope
37 | if(i==0) x+=a[i];
| ^
a.cc:38:10: error: 'y' was not declared in this scope
38 | else y+=a[i];
| ^
a.cc:40:13: error: 'x' was not declared in this scope
40 | ans = abs(x-y);
| ^
a.cc:40:15: error: 'y' was not declared in this scope
40 | ans = abs(x-y);
| ^
|
s149507741 | p03659 | C++ | #include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
int main(){
int N; cin >> N;
int a[N];
ll b[N];
ll tot = 0;
rep(i,N) {
cin >> a[i];
if (i==0) b[i] = a[i];
else b[i] = b[i-1] + a[i];
tot += abs(a[i]);
}
ll retval = tot;
rep(i,N-1){
retval = min(retval, abs(b[N-1]-2*b[i]);
}
cout << retval << endl;
// cout << fixed << setprecision(10);
return 0;
}
| a.cc: In function 'int main()':
a.cc:26:44: error: expected ')' before ';' token
26 | retval = min(retval, abs(b[N-1]-2*b[i]);
| ~ ^
| )
|
s749450879 | p03659 | C++ | int main(void)
{
int N;
cin >> N;
vector<ll> a(N);
for (int i = 0; i < N; i++)
{
cin >> a[i];
}
vector<ll> b(N);
b = a;
reverse(b.begin(), b.end());
int M = N + 1;
vector<ll> rui1(M, 0);
vector<ll> rui2(M, 0);
for (int i = 0; i < M; ++i)
{
rui1[i + 1] = rui1[i] + a[i];
}
for (int i = 0; i < M; ++i)
{
rui2[i + 1] = rui2[i] + b[i];
}
ll diff = LINF;
ll ans = LINF;
for (int i = 1; i < N; i++)
{
ll num1 = rui1[i];
ll num2 = rui2[N - i];
printf("%d - %d\n", num1, num2);
diff = abs(num1 - num2);
ans = min(ans, diff);
}
cout << ans << "\n";
return (0);
} | a.cc: In function 'int main()':
a.cc:4:5: error: 'cin' was not declared in this scope
4 | cin >> N;
| ^~~
a.cc:6:5: error: 'vector' was not declared in this scope
6 | vector<ll> a(N);
| ^~~~~~
a.cc:6:12: error: 'll' was not declared in this scope
6 | vector<ll> a(N);
| ^~
a.cc:6:16: error: 'a' was not declared in this scope
6 | vector<ll> a(N);
| ^
a.cc:11:16: error: 'b' was not declared in this scope
11 | vector<ll> b(N);
| ^
a.cc:13:5: error: 'reverse' was not declared in this scope
13 | reverse(b.begin(), b.end());
| ^~~~~~~
a.cc:16:16: error: 'rui1' was not declared in this scope
16 | vector<ll> rui1(M, 0);
| ^~~~
a.cc:17:16: error: 'rui2' was not declared in this scope
17 | vector<ll> rui2(M, 0);
| ^~~~
a.cc:27:7: error: expected ';' before 'diff'
27 | ll diff = LINF;
| ^~~~~
| ;
a.cc:28:7: error: expected ';' before 'ans'
28 | ll ans = LINF;
| ^~~~
| ;
a.cc:31:11: error: expected ';' before 'num1'
31 | ll num1 = rui1[i];
| ^~~~~
| ;
a.cc:32:11: error: expected ';' before 'num2'
32 | ll num2 = rui2[N - i];
| ^~~~~
| ;
a.cc:33:29: error: 'num1' was not declared in this scope
33 | printf("%d - %d\n", num1, num2);
| ^~~~
a.cc:33:35: error: 'num2' was not declared in this scope
33 | printf("%d - %d\n", num1, num2);
| ^~~~
a.cc:33:9: error: 'printf' was not declared in this scope
33 | printf("%d - %d\n", num1, num2);
| ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
+++ |+#include <cstdio>
1 | int main(void)
a.cc:34:9: error: 'diff' was not declared in this scope
34 | diff = abs(num1 - num2);
| ^~~~
a.cc:34:16: error: 'abs' was not declared in this scope
34 | diff = abs(num1 - num2);
| ^~~
a.cc:35:9: error: 'ans' was not declared in this scope
35 | ans = min(ans, diff);
| ^~~
a.cc:35:15: error: 'min' was not declared in this scope; did you mean 'main'?
35 | ans = min(ans, diff);
| ^~~
| main
a.cc:37:5: error: 'cout' was not declared in this scope
37 | cout << ans << "\n";
| ^~~~
a.cc:37:13: error: 'ans' was not declared in this scope
37 | cout << ans << "\n";
| ^~~
|
s632917466 | p03659 | C++ | //解説の別解
// 左がxとすると右はsum-xなので
// 最小のabs(sum-2x)をみつける
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
// const int INF = 2147483647;
const ll INF = 1000000000000000000LL;
int main(){
int n;
cin >> n;
vector<int> a(n);
ll sum=0;
rep(i,n){
cin >> a[i];
sum+=a[i];
}
ll x=0;
ll ans = INF;
for(int i=0;i<n;i++){
x+=a[i];
// 2人とも1枚ずつとらなきゃだめ
if(i+1<n) ans=min(ans,abs(X-2*x));
}
return 0;
} | a.cc: In function 'int main()':
a.cc:25:43: error: 'X' was not declared in this scope
25 | if(i+1<n) ans=min(ans,abs(X-2*x));
| ^
|
s154969530 | p03659 | C++ | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
int main()
{
long n; cin >> n;
long sum = 0;
vector<long> v(n);
long total = 0;
rep(i, n)
{
cin >> v[i];
total += v[i];
}
priority_queue<long, vector<long>, greater<long> > q;
rep(i, n-1)
{
sum+=v[i];
q.push(labs(total - (total - sum));
}
cout << q.top() << endl;
return (0);
} | a.cc: In function 'int main()':
a.cc:21:51: error: expected ')' before ';' token
21 | q.push(labs(total - (total - sum));
| ~ ^
| )
|
s761343010 | p03659 | C++ | #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
//---------------------------------------------------------------------------------------------------
template<int MOD> struct ModInt {
static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
int get() const { return (int)x; }
ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
return ModInt(u); }
bool operator==(ModInt that) const { return x == that.x; }
bool operator!=(ModInt that) const { return x != that.x; }
ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
template<typename T, int FAC_MAX> struct Comb { vector<T> fac, ifac;
Comb(){fac.resize(FAC_MAX,1);ifac.resize(FAC_MAX,1);FOR(i,1,FAC_MAX-1)fac[i]=fac[i-1]*i;
ifac[FAC_MAX-1]=T(1)/fac[FAC_MAX-1];for(int i=FAC_MAX-2;i>=1;i--)ifac[i]=ifac[i+1]*T(i+1);}
T aPb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b]; }
T aCb(int a, int b) { if (b < 0 || a < b) return T(0); return fac[a] * ifac[a - b] * ifac[b]; }
T nHk(int n, int k) { if (n == 0 && k == 0) return T(1); if (n <= 0 || k < 0) return 0;
return aCb(n + k - 1, k); } // nHk = (n+k-1)Ck : n is separator
T pairCombination(int n) {if(n%2==1)return T(0);return fac[n]*ifac[n/2]/(T(2)^(n/2));}
// combination of paris for n
};
typedef ModInt<1000000007> mint;
int main(void){
// Your code here!
int n; cin >> n;
vector<ll> a(n);
rep(i,n) cin >> a[i];
ll su = SUM(a,0);
ll ans = INF;
ll snuke = 0;
rep(i,n-1) {
snuke += a[i];
if(ans > abs(su-2*snuke)) {
ans = abs(su-2*snuke);
} else {
break;
}
}
cout << ans << endl;
}
z | a.cc:73:1: error: 'z' does not name a type
73 | z
| ^
|
s541954799 | p03659 | 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>
#include <array>
#include <atomic>
#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;
using ll = int64_t;
#define MAX_N 1010
#define MAX_M 100010
const long long mod = pow(10, 9) + 7;
#define vect vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define ent cout<<endl
#define printvec(vect) for(int aqw=0;aqw<vect.size();aqw++){cout<<vect[aqw]<<" ";}ent;
#define rep1(n) for(ll i = 0; i < (n); ++i)
#define rep2(i, n) for(ll i = 0; i < (n); ++i)
#define rep3(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep4(i, a, b, c) for(ll i = (a); i < (b); i += (c))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define INF 1e+9
#define print(x) cout<<x<<endl;
using P = pair<int, int>;
#define PLL pair<ll, ll>;
#define MAX_V 10010
#define PI 3.141592653589793
#define vecP vector<P>
//cout << setprecision(15) << std::fixed;
int main() {
ll n,b,m=0;
cin >> n;
vecll A(n,0);
for (int i = 0;i < n;i++) {
cin >> A[i];
m += A[i];
}
ll ans = INF;
for (int i = 0;i < n;i++) {
b += A[i];
if (i + 1 < n) ans = min(ans, abs(m - 2 * b));
}
print(ans);
}#include <bits/stdc++.h>
using namespace std;
void solve(long long N, std::vector<long long> a) {}
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
long long N;
scanf("%lld", &N);
std::vector<long long> a(N);
for (int i = 0; i < N; i++) {
scanf("%lld", &a[i]);
}
solve(N, std::move(a));
return 0;
}
| a.cc:101:2: error: stray '#' in program
101 | }#include <bits/stdc++.h>
| ^
a.cc:101:3: error: 'include' does not name a type
101 | }#include <bits/stdc++.h>
| ^~~~~~~
a.cc:109:5: error: redefinition of 'int main()'
109 | int main() {
| ^~~~
a.cc:87:5: note: 'int main()' previously defined here
87 | int main() {
| ^~~~
|
s003034852 | p03659 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
int main() {
int n; cin >> n;
if (n == 2) {
int a1, a2; cin >> a1 >> a2;
cout << abs(a1 - a2) << endl;
return 0;
}
vector<ll> accum(n + 1, 0);
for (int i = 1; i <= n; i++) {
ll tmp_a; cin >> tmp_a;
accum[i] += accum[i - 1];
accum[i] += tmp_a;
}
ll ll = 9223372036854775807LL;
for (int i = 1; i <= n; i++) {
ll left = accum[i];
ll right = accum[n] - accum[i];
ll sum = abs(left - right);
ans = min(ans, sum);
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:25:11: error: expected ';' before 'left'
25 | ll left = accum[i];
| ^~~~~
| ;
a.cc:26:11: error: expected ';' before 'right'
26 | ll right = accum[n] - accum[i];
| ^~~~~~
| ;
a.cc:27:11: error: expected ';' before 'sum'
27 | ll sum = abs(left - right);
| ^~~~
| ;
a.cc:28:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
28 | ans = min(ans, sum);
| ^~~
| abs
a.cc:28:24: error: 'sum' was not declared in this scope
28 | ans = min(ans, sum);
| ^~~
a.cc:31:13: error: 'ans' was not declared in this scope; did you mean 'abs'?
31 | cout << ans << endl;
| ^~~
| abs
|
s704837348 | p03659 | C++ | #include <bits/stdc++.h>
#define l long long
using namespace std;
int main() {
ll n;
cin>>n;
ll arr[n];
for(ll i=0;i<n;i++)
cin>>arr[i];
ll pre_sum[n], pre_rsum[n];
pre_sum[0] = arr[0];
pre_rsum[n-1] = arr[n-1];
for(ll i=1;i<n;i++)
pre_sum[i] = pre_sum[i-1] + arr[i];
for(ll i=n-2;i>=0;i--)
pre_rsum[i] = pre_rsum[i+1] + arr[i];
ll ans = ll_MAX;
for(ll i=0;i<n;i++)
{
ans = min(ans, abs(pre_sum[i]-pre_rsum[i+1]));
}
cout<<ans;
return 0;
} | a.cc: In function 'int main()':
a.cc:9:5: error: 'll' was not declared in this scope; did you mean 'l'?
9 | ll n;
| ^~
| l
a.cc:10:10: error: 'n' was not declared in this scope; did you mean 'yn'?
10 | cin>>n;
| ^
| yn
a.cc:11:7: error: expected ';' before 'arr'
11 | ll arr[n];
| ^~~~
| ;
a.cc:12:11: error: expected ';' before 'i'
12 | for(ll i=0;i<n;i++)
| ^~
| ;
a.cc:12:16: error: 'i' was not declared in this scope
12 | for(ll i=0;i<n;i++)
| ^
a.cc:13:10: error: 'arr' was not declared in this scope
13 | cin>>arr[i];
| ^~~
a.cc:14:7: error: expected ';' before 'pre_sum'
14 | ll pre_sum[n], pre_rsum[n];
| ^~~~~~~~
| ;
a.cc:16:5: error: 'pre_sum' was not declared in this scope
16 | pre_sum[0] = arr[0];
| ^~~~~~~
a.cc:16:18: error: 'arr' was not declared in this scope
16 | pre_sum[0] = arr[0];
| ^~~
a.cc:17:5: error: 'pre_rsum' was not declared in this scope
17 | pre_rsum[n-1] = arr[n-1];
| ^~~~~~~~
a.cc:19:11: error: expected ';' before 'i'
19 | for(ll i=1;i<n;i++)
| ^~
| ;
a.cc:19:16: error: 'i' was not declared in this scope
19 | for(ll i=1;i<n;i++)
| ^
a.cc:21:11: error: expected ';' before 'i'
21 | for(ll i=n-2;i>=0;i--)
| ^~
| ;
a.cc:21:18: error: 'i' was not declared in this scope
21 | for(ll i=n-2;i>=0;i--)
| ^
a.cc:24:7: error: expected ';' before 'ans'
24 | ll ans = ll_MAX;
| ^~~~
| ;
a.cc:25:11: error: expected ';' before 'i'
25 | for(ll i=0;i<n;i++)
| ^~
| ;
a.cc:25:16: error: 'i' was not declared in this scope
25 | for(ll i=0;i<n;i++)
| ^
a.cc:27:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
27 | ans = min(ans, abs(pre_sum[i]-pre_rsum[i+1]));
| ^~~
| abs
a.cc:29:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
29 | cout<<ans;
| ^~~
| abs
|
s189288691 | p03659 | C++ | #include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n);i++)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
int n;
cin >> n;
int a = 0;
int b = 0;
int ans = 1e9;
vector<int> x(n);
rep(i,n){
cin >> x[i];
a += x[i];
}
rep(i,n-1){
b += x[i];
ans = min(ans,abc(a-b*2));
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:20:23: error: 'abc' was not declared in this scope; did you mean 'abs'?
20 | ans = min(ans,abc(a-b*2));
| ^~~
| abs
|
s476248512 | p03659 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
long long N;
cin>>N;
vector<long long>A(N);
vector<long long>sum(N);
sum.at(0)=0;
for(int i=0;i<N;i++){
cin>>A.at(i);
if(i==0){
sum.at(i)=A.at(i);
}
else{
sum.at(i)=sum.at(i-1)+A.at(i);
}
}
long long ans=1000000000;
for(int i=1:i<N-1;i++){
ans=min(ans,abs(sum.at(i)*2-sum.at(N-1)));
}
cout<<ans<<endl;
}
| a.cc: In function 'int main()':
a.cc:19:12: error: initializer in range-based 'for' loop
19 | for(int i=1:i<N-1;i++){
| ^
a.cc:19:20: error: expected ')' before ';' token
19 | for(int i=1:i<N-1;i++){
| ~ ^
| )
a.cc:19:21: error: 'i' was not declared in this scope
19 | for(int i=1:i<N-1;i++){
| ^
|
s657744745 | p03659 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<double> VL;
typedef vector<string> VS;
typedef vector<PLL> VP;
typedef vector<ll> VLL;
const static int INF = 1000000000;
const static int MOD = 1000000007;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];
void cum_sum(int N,vector<ll> a, vector<ll> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
if(b == 0) return a;
return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
ll g = gcd(a,b);
return a / g * b; // Be careful not to overflow
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision
int main()
{
int N;
cin >> N;
VLL a(N);
ll X=0;
rep(i,N){
cin >> a[i];
X+=a[i];
}
ll x=0;
ll ans=INF;
rep(i=0; i<N; i++){
x+=a[i];
if(i<N-1){
ans=min(ans,abs(X-2*x));
}
}
cout << ans << endl;
}
| a.cc:56:22: error: macro "rep" requires 2 arguments, but only 1 given
56 | rep(i=0; i<N; i++){
| ^
a.cc:14:9: note: macro "rep" defined here
14 | #define rep(i,n) for (ll i=0; i<(ll)(n); i++)
| ^~~
a.cc: In function 'int main()':
a.cc:56:5: error: 'rep' was not declared in this scope
56 | rep(i=0; i<N; i++){
| ^~~
|
s652565963 | p03659 | C++ | #include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
int n;
cin>>n;
ll ara[n+5];
ll sum=0;
for(int i=0;i<n;i++)cin>>ara[i],sum+=ara[i];
ll cur=0;
ll mn=12345678901234567;
for(int i=0;i<n-1;i++)
{
cur+=ara[i];
ll left=sum-cur;
mn=min(mn,abs(cur-left);
}
cout<<mn<<endl;
} | a.cc: In function 'int main()':
a.cc:17:28: error: expected ')' before ';' token
17 | mn=min(mn,abs(cur-left);
| ~ ^
| )
|
s658553737 | p03659 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
long long N;
cin>>N;
vector<int>cards(N);
int sum=0;
for(int i=0;i<N;i++){
cin>>cards.at(i);
sum+=cards.at(i);
}
//cout<<cards.at(1)<<endl;
long long a_sum=0;
vector<int>results(N);
for(int i =0;i<N-1;i++){
a_sum+=cards.at(0);
results.at(i)=abs(2*a_sum-sum);
}
sort(results.begin(),results.end());
cout<<results.at(1)<<endl; | a.cc: In function 'int main()':
a.cc:24:31: error: expected '}' at end of input
24 | cout<<results.at(1)<<endl;
| ^
a.cc:4:12: note: to match this '{'
4 | int main() {
| ^
|
s116928491 | p03659 | C++ | #include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef vector<int> vi;
const int mod = 1000000007;
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,sum,no;
cin>>n;
int pref[n];
cin>>no;
pref[0]=no;
for(int i =1;i<n;i++){
cin>>no;
pref[i] = pref[i-1] + no;
sum = pref[n-1];
int ans=1e9;
for(int i =0;i < n-1;i++){
int x = sum - pref[i];
ans = min(ans,abs(pref[i]-x));
}
cout<<ans<<endl;
}
| a.cc: In function 'int32_t main()':
a.cc:41:2: error: expected '}' at end of input
41 | }
| ^
a.cc:16:16: note: to match this '{'
16 | int32_t main() {
| ^
|
s933978412 | p03659 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
int N;
cin >> N;
ll a[N];
ll r[N] = {0};
for (int i = 0; i < N; i++) {
cin >> a[i];
}
r[0] = a[0];
for (int i = 1; i < N; i++) {
r[i] = r[i - 1] + a[i];
}
ll ans = 9999999999999;
for (int i = 0; i < N - 1; i++) {
ans = min(ans,abs(r[N - 1] - r[i] - r[i]))
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:18:47: error: expected ';' before '}' token
18 | ans = min(ans,abs(r[N - 1] - r[i] - r[i]))
| ^
| ;
19 | }
| ~
|
s153356365 | p03659 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main() {
ll n;
vl a(n);
ll sum=0;
vl sum2(n,0);
rep(i,n){
cin >> a[i];
sum +=a[i];
}
sum2[0]=a[0];
FOR(i,1,n){
sum2[i]=sum2[i-1]+a[i];
}
ll ans=INF;
rep(i,n-1){
ans=min(ans,sum-2*sum2);
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:30:22: error: no match for 'operator*' (operand types are 'int' and 'vl' {aka 'std::vector<long long int>'})
30 | ans=min(ans,sum-2*sum2);
| ~^~~~~
| | |
| | vl {aka std::vector<long long int>}
| int
In file included from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
from a.cc:1:
/usr/include/c++/14/complex:400:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const complex<_Tp>&, const complex<_Tp>&)'
400 | operator*(const complex<_Tp>& __x, const complex<_Tp>& __y)
| ^~~~~~~~
/usr/include/c++/14/complex:400:5: note: template argument deduction/substitution failed:
a.cc:30:23: note: mismatched types 'const std::complex<_Tp>' and 'int'
30 | ans=min(ans,sum-2*sum2);
| ^~~~
/usr/include/c++/14/complex:409:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const complex<_Tp>&, const _Tp&)'
409 | operator*(const complex<_Tp>& __x, const _Tp& __y)
| ^~~~~~~~
/usr/include/c++/14/complex:409:5: note: template argument deduction/substitution failed:
a.cc:30:23: note: mismatched types 'const std::complex<_Tp>' and 'int'
30 | ans=min(ans,sum-2*sum2);
| ^~~~
/usr/include/c++/14/complex:418:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const _Tp&, const complex<_Tp>&)'
418 | operator*(const _Tp& __x, const complex<_Tp>& __y)
| ^~~~~~~~
/usr/include/c++/14/complex:418:5: note: template argument deduction/substitution failed:
a.cc:30:23: note: 'vl' {aka 'std::vector<long long int>'} is not derived from 'const std::complex<_Tp>'
30 | ans=min(ans,sum-2*sum2);
| ^~~~
In file included from /usr/include/c++/14/valarray:605,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166:
/usr/include/c++/14/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)'
407 | _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note: template argument deduction/substitution failed:
a.cc:30:23: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int'
30 | ans=min(ans,sum-2*sum2);
| ^~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)'
407 | _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note: template argument deduction/substitution failed:
a.cc:30:23: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int'
30 | ans=min(ans,sum-2*sum2);
| ^~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)'
407 | _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note: template argument deduction/substitution failed:
a.cc:30:23: note: 'vl' {aka 'std::vector<long long int>'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
30 | ans=min(ans,sum-2*sum2);
| ^~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)'
407 | _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note: template argument deduction/substitution failed:
a.cc:30:23: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int'
30 | ans=min(ans,sum-2*sum2);
| ^~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__multiplies, typename _Dom1::value_type>::result_type> std::operator*(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)'
407 | _DEFINE_EXPR_BINARY_OPERATOR(*, struct std::__multiplies)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/valarray_after.h:407:5: note: template argument deduction/substitution failed:
a.cc:30:23: note: 'vl' {aka 'std::vector<long long int>'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>'
30 | ans=min(ans,sum-2*sum2);
| ^~~~
/usr/include/c++/14/valarray:1198:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__multiplies, _Tp>::result_type> std::operator*(const valarray<_Tp>&, const valarray<_Tp>&)'
1198 | _DEFINE_BINARY_OPERATOR(*, __multiplies)
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1198:1: note: template argument deduction/substitution failed:
a.cc:30:23: note: mismatched types 'const std::valarray<_Tp>' and 'int'
30 | ans=min(ans,sum-2*sum2);
| ^~~~
/usr/include/c++/14/valarray:1198:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__multiplies, _Tp>::result_type> std::operator*(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)'
1198 | _DEFINE_BINARY_OPERATOR(*, __multiplies)
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1198:1: note: template argument deduction/substitution failed:
a.cc:30:23: note: mismatched types 'const std::valarray<_Tp>' and 'int'
30 | ans=min(ans,sum-2*sum2);
| ^~~~
/usr/include/c++/14/valarray:1198:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__multiplies, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__multiplies, _Tp>::result_type> std::operator*(const typename valarray<_Tp>::value_type&, const valarray<_Tp>&)'
1198 | _DEFINE_BINARY_OPERATOR(*, __multiplies)
| ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/valarray:1198:1: note: template argument deduction/substitution failed:
a.cc:30:23: note: 'vl' {aka 'std::vector<long long int>'} is not derived from 'const std::valarray<_Tp>'
30 | ans=min(ans,sum-2*sum2);
| ^~~~
|
s979971233 | p03659 | C++ | #include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;
int main() {
int n, a;
cin >> n;
vector<int> input;
for (int i=0; i<n; ++i) {
cin >> a;
input.push_back(a);
}
int sum = 0;
for (auto&e : input) {
sum += e;
}
int minDiff = INT_MAX;
int x = 0, y = sum;
for (int i=0; i < input.size()-1; ++i) {
x += input[i];
y -= input[i];
minDiff = min(minDiff, abs(x - y));
}
cout << minDiff << endl;
}
| a.cc: In function 'int main()':
a.cc:11:5: error: 'vector' was not declared in this scope
11 | vector<int> input;
| ^~~~~~
a.cc:5:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
4 | #include <algorithm>
+++ |+#include <vector>
5 |
a.cc:11:12: error: expected primary-expression before 'int'
11 | vector<int> input;
| ^~~
a.cc:14:9: error: 'input' was not declared in this scope; did you mean 'int'?
14 | input.push_back(a);
| ^~~~~
| int
a.cc:17:19: error: 'input' was not declared in this scope; did you mean 'int'?
17 | for (auto&e : input) {
| ^~~~~
| int
a.cc:23:23: error: 'input' was not declared in this scope; did you mean 'int'?
23 | for (int i=0; i < input.size()-1; ++i) {
| ^~~~~
| int
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.