submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s157734346 | p03862 | C++ | #include<bits/stdc++.h>
# define ll long long
using namespace std;
int main(){
ll n,x;
cin >> n >> x;
ll arr[n];
ll sum;ll ans;
for ( int i = 0 ; i < n ;i++){
cin >> a[i];
}
if ( a[0] > x ) {
ans += a[0] - x;
a[0] = x;
}
sum = a[0];
for ( int i = 1 ; i < n ; i++){
sum += a[i];
if (sum > x){
ans += sum-x;
a[i] -= sum-x;
sum = x;
}
sum -= a[i-1];
}
cout << ans;
}
} | a.cc: In function 'int main()':
a.cc:11:10: error: 'a' was not declared in this scope
11 | cin >> a[i];
| ^
a.cc:13:8: error: 'a' was not declared in this scope
13 | if ( a[0] > x ) {
| ^
a.cc:17:15: error: 'a' was not declared in this scope
17 | sum = a[0];
| ^
a.cc: At global scope:
a.cc:30:1: error: expected declaration before '}' token
30 | }
| ^
|
s641855768 | p03862 | Java | mport java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int x = sc.nextInt();
int ops = 0;
int[] candies = new int[n];
for(int i = 0; i < n; i++){
candies[i] = sc.nextInt();
}
for(int i = 0; i < n - 1; i++){
int diff = (candies[i] + candies[i + 1]) - x;
if (diff > 0){
ops += diff;
if (diff < candies[i + 1]){
candies[i + 1] -= diff;
}
else{
candies[i + 1] = 0;
}
}
}
System.out.println(ops);
sc.close();
}
} | Main.java:1: error: class, interface, enum, or record expected
mport java.util.Scanner;
^
1 error
|
s598076555 | p03862 | C++ | #include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5+5;
typedef long long ll;
ll a[MAX_N];
int main()
{
ll n, x, ans = 0;
cin >> n >> x;
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 1; i < n; i++)
{
if (a[i]+a[i-1] > x) ans += a[i]+a[i-1]-x, a[i] = max(0, x-a[i-1]);
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:15:70: error: no matching function for call to 'max(int, ll)'
15 | if (a[i]+a[i-1] > x) ans += a[i]+a[i-1]-x, a[i] = max(0, x-a[i-1]);
| ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:15:70: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
15 | if (a[i]+a[i-1] > x) ans += a[i]+a[i-1]-x, a[i] = max(0, x-a[i-1]);
| ~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:15:70: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
15 | if (a[i]+a[i-1] > x) ans += a[i]+a[i-1]-x, a[i] = max(0, x-a[i-1]);
| ~~~^~~~~~~~~~~~~
|
s062058736 | p03862 | C++ | #include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5+5;
typedef long long ll;
ll a[MAX_N];
int main()
{
ll n, x, ans = 0;
cin >> n >> x;
for (int i = 0; i < n; i++) cin >> a[i];
for (int i = 1; i < n; i++)
{
if (a[i]+a[i+1] > x) ans += a[i]+a[i-1]-x, a[i] = max(0, x-a[i-1]);
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:15:70: error: no matching function for call to 'max(int, ll)'
15 | if (a[i]+a[i+1] > x) ans += a[i]+a[i-1]-x, a[i] = max(0, x-a[i-1]);
| ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:15:70: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
15 | if (a[i]+a[i+1] > x) ans += a[i]+a[i-1]-x, a[i] = max(0, x-a[i-1]);
| ~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:15:70: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
15 | if (a[i]+a[i+1] > x) ans += a[i]+a[i-1]-x, a[i] = max(0, x-a[i-1]);
| ~~~^~~~~~~~~~~~~
|
s954428124 | p03862 | C++ | #include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
int main(){
unsigned long long int N, x; cin >> N >> x;
unsigned long long int a[N]; rep(i,N) cin >> a[i];
unsigned long long int cnt = 0;
rep(i,N-1){
int b = a[i+1] + a[i];
if(i % 2 == 0){
if(b > x){
int tmp = a[i+1];
a[i+1] = max(a[i+1]-(b-x), 0);
cnt += tmp - a[i+1];
b = a[i+1] + a[i];
}
if(b > x){
a[i] = a[i]-(b-x);
cnt += b-x;
}
}
else{
if(b > x){
int tmp = a[i];
a[i] = max(a[i]-(b-x), 0);
cnt += tmp - a[i];
b = a[i+1] + a[i];
}
if(b > x){
a[i+1] = a[i+1]-(b-x);
cnt += b-x;
}
}
}
cout << cnt << endl;
} | a.cc: In function 'int main()':
a.cc:15:29: error: no matching function for call to 'max(long long unsigned int, int)'
15 | a[i+1] = max(a[i+1]-(b-x), 0);
| ~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:15:29: note: deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'int')
15 | a[i+1] = max(a[i+1]-(b-x), 0);
| ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:15:29: note: mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
15 | a[i+1] = max(a[i+1]-(b-x), 0);
| ~~~^~~~~~~~~~~~~~~~~
a.cc:27:27: error: no matching function for call to 'max(long long unsigned int, int)'
27 | a[i] = max(a[i]-(b-x), 0);
| ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:27:27: note: deduced conflicting types for parameter 'const _Tp' ('long long unsigned int' and 'int')
27 | a[i] = max(a[i]-(b-x), 0);
| ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:27:27: note: mismatched types 'std::initializer_list<_Tp>' and 'long long unsigned int'
27 | a[i] = max(a[i]-(b-x), 0);
| ~~~^~~~~~~~~~~~~~~
|
s507154693 | p03862 | C++ | #include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
typedef long long int ll;
using namespace std;
int main(int argc, char const *argv[]) {
ll N, X;
std::cin >> N >> X;
std::vector<ll> A(N);
std::vector<pair<ll, ll> > dp(N);
for(int i=0;i<N;i++) std::cin >> A[i];
for(int i=0;i<N;i++){
if(i==0) dp[0] = (A[0]<=X?make_pair(0, A[0]):make_pair(A[0]-X, X));
else dp[i] = (A[i]+dp[i-1].second<=X?make_pair(dp[i-1].first, A[i]):make_pair(dp[i-1].first+A[i]+dp[i-1].second-X, X-dp[i-1].second));
//std::cout << dp[i].first << " " << dp[i].second<< '\n';
}
std::cout << dp[N-1].first << '\n';
return 0;
}
| a.cc: In function 'int main(int, const char**)':
a.cc:24:30: error: operands to '?:' have different types 'std::pair<int, long long int>' and 'std::pair<long long int, long long int>'
24 | if(i==0) dp[0] = (A[0]<=X?make_pair(0, A[0]):make_pair(A[0]-X, X));
a.cc:24:30: note: and each type can be converted to the other
|
s782447482 | p03862 | C++ | #include<bits/stdc++.h>
using namespace std;
int main()
{
int n,x;
cin>>n>>x;
vector<int> a(n);
for(auto &i:a)
cin>>i;
long long int ans=0;
for(int i=0;i<n-1;i++)
if(a[i]+a[i+1]>x)
{
long long sub = a[i+1]+a[i]-x;
ans += sub;
a[i+1]=max(a[i+1]-sub,0);
}
if(a[n-1]>x)
ans += a[n-1]-x;
cout<<ans<<"\n";
return 0;
}
| a.cc: In function 'int main()':
a.cc:17:19: error: no matching function for call to 'max(long long int, int)'
17 | a[i+1]=max(a[i+1]-sub,0);
| ~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:17:19: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
17 | a[i+1]=max(a[i+1]-sub,0);
| ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:17:19: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
17 | a[i+1]=max(a[i+1]-sub,0);
| ~~~^~~~~~~~~~~~~~
|
s411175063 | p03862 | C | ;;; 048 C - Boxes and Candies
(define (input n)
(let loop ((ls ()) (n n))
(if (zero? n) ls (loop (cons (read) ls) (- n 1)))))
(define (main arg)
(let* ((n (read)) (x (read)) (ls (input n)))
(let loop ((ls ls) (ans 0))
(cond ((null? (cdr ls)) (print ans))
(else
(let ((ret 0))
(set! ret (max (+ (car ls) (cadr ls) (- x)) 0))
(dec! (car ls) (max (- ret (cadr ls)) 0))
(dec! (cadr ls) (min ret (cadr ls)))
(loop (cdr ls) (+ ret ans)))))))
0)
| main.c:1:5: error: invalid digit "8" in octal constant
1 | ;;; 048 C - Boxes and Candies
| ^~~
main.c:1:5: error: expected identifier or '(' before numeric constant
|
s441839985 | p03862 | C++ | ℣#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repn(i,n) for(ll i=0;i<=(ll)(n);i++)
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
//cin.tie(0);
//ios::sync_with_stdio(false);
signed main(){
ll n,x,ans=0;cin>>n>>x;
vector<ll> v(n,0);
for(int i=0;i < n;i++)
{
cin>>v[i];
}
for(int i=1;i < n;i++)
{
if(v[i-1]+v[i]>x){
ans+=v[i-1]+v[i]-x;
v[i]=min(x-v[i-1],0ll);
}
}
cout<<ans<<endl;
}
| a.cc:1:2: error: stray '#' in program
1 | ℣#include <bits/stdc++.h>
| ^
a.cc:1:1: error: '\U00002123' does not name a type
1 | ℣#include <bits/stdc++.h>
| ^
a.cc:12:9: error: 'pair' does not name a type
12 | typedef pair<int,int> P;
| ^~~~
a.cc:13:9: error: 'pair' does not name a type
13 | typedef pair<ll,ll> PL;
| ^~~~
a.cc: In function 'int main()':
a.cc:20:16: error: 'cin' was not declared in this scope
20 | ll n,x,ans=0;cin>>n>>x;
| ^~~
a.cc:22:3: error: 'vector' was not declared in this scope
22 | vector<ll> v(n,0);
| ^~~~~~
a.cc:22:12: error: expected primary-expression before '>' token
22 | vector<ll> v(n,0);
| ^
a.cc:22:14: error: 'v' was not declared in this scope
22 | vector<ll> v(n,0);
| ^
a.cc:32:12: error: 'min' was not declared in this scope; did you mean 'main'?
32 | v[i]=min(x-v[i-1],0ll);
| ^~~
| main
a.cc:35:3: error: 'cout' was not declared in this scope
35 | cout<<ans<<endl;
| ^~~~
a.cc:35:14: error: 'endl' was not declared in this scope
35 | cout<<ans<<endl;
| ^~~~
|
s447920101 | p03862 | C++ | #include <bits/stdc++.h>
using namespace std;
int n,a[100000],x,sum=0;
int main(){
cin>>n>>x;
for(int i=0;i<n;i++) cin>>a[i];
for(int i=0;i<n-1;i++)
{
if((a[i]+a[i+1])>x)
{ sum+=m;
if(a[k+1]>=m) a[k+1]-=m;
else{a[k+1]=0;}
}
cout<<sum;
return 0;
} | a.cc: In function 'int main()':
a.cc:13:22: error: 'm' was not declared in this scope
13 | { sum+=m;
| ^
a.cc:14:14: error: 'k' was not declared in this scope
14 | if(a[k+1]>=m) a[k+1]-=m;
| ^
a.cc:19:2: error: expected '}' at end of input
19 | }
| ^
a.cc:7:11: note: to match this '{'
7 | int main(){
| ^
|
s280172714 | p03862 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll N, x; cin >> N >> x;
vector<ll> A(N, 0);
for (int i = 0; i < N; i++) { cin >> A[i]; }
ll count = 0;
for (int i = 1; i < N; i++) {
ll oldi = A[i];
if (A[i - 1] + A[i] > x) {
// count += ;
A[i] = (x - A[i - 1]);
count += oldi - A[i] ;
}.
}
// for (auto v : A) { cout << v << " "; } cout << endl;
cout << count << endl;
} | a.cc: In function 'int main()':
a.cc:19:10: error: expected primary-expression before '.' token
19 | }.
| ^
a.cc:20:5: error: expected unqualified-id before '}' token
20 | }
| ^
|
s209936617 | p03862 | C++ | #include<cstdio>
int main(){
int n;
long long x;
scanf("%d %lld", &n, &x);
long long a[100000];
for(int i=0; i<n; i++)
scanf("%lld", &a[i]);
long long ans = 0;
if(a[0]>x){
ans = a[0] - x;
a[0] -= x;
if(x == 0){
ans = a[0];
a[0] = 0;
}
for(int i=0; i<(n-1); i++){
long long sum = a[i] + a[i+1];
if( sum > x ){
long long diff = sum - x;
ans += diff;
a[i+1] -= diff;
}
}
printf("%lld", ans);
return 0;
}
| a.cc: In function 'int main()':
a.cc:30:2: error: expected '}' at end of input
30 | }
| ^
a.cc:2:11: note: to match this '{'
2 | int main(){
| ^
|
s875755629 | p03862 | C++ | #include<cstdio>
int main(){
int n;
long long x;
scanf("%d %lld", &n, &x);
long long a[10000000000];
for(int i=0; i<n; i++)
scanf("%lld", &a[i]);
long long ans = 0;
if(a[0]>x){
ans = a[0] - x;
a[0] -= x;
}
for(int i=0; i<(n-1); i++){
if( a[i]+a[i+1] >= x ){
diff = a[i+1] - x;
ans += diff;
a[i+1] -= diff;
}
}
printf("%lld", ans);
return 0;
}
| a.cc: In function 'int main()':
a.cc:19:7: error: 'diff' was not declared in this scope
19 | diff = a[i+1] - x;
| ^~~~
|
s340163152 | p03862 | C++ | #include<cstdio>
int main(){
int n, x;
scanf("%d %d", &n, &x);
long int a[];
for(int i=0; i<n, i++)
scanf("%d", &a[i]);
long long ans = 0;
while(a[0]>x){
a[0]--;
ans++;
}
for(int i; i<(n-1); i++){
while( a[i]+a[i+1] >= x ){
a[i+1]--;
ans++;
}
}
printf("%lld", ans);
return 0;
} | a.cc: In function 'int main()':
a.cc:6:12: error: storage size of 'a' isn't known
6 | long int a[];
| ^
a.cc:7:24: error: expected ';' before ')' token
7 | for(int i=0; i<n, i++)
| ^
| ;
|
s523251444 | p03862 | C++ | #include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
int main() {
int N, x;
cin >> N >> x;
rep(i, N) {
cin >> a[i];
}
ll ans = 0;
rep(i, N-1) {
if(a[i]+a[i+1] <= x) {
continue;
}
else if(a[i] <= x) {
ans += a[i] + a[i+1] - x;
a[i+1] = x - a[i];
}
else if(x < a[i]) {
ans += (a[i] + a[i+1]) - x;
a[i+1] = 0;
}
}
cout << ans;
cout << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:15:16: error: 'a' was not declared in this scope
15 | cin >> a[i];
| ^
a.cc:20:12: error: 'a' was not declared in this scope
20 | if(a[i]+a[i+1] <= x) {
| ^
|
s463093189 | p03862 | C++ | #include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long arr[100002];
int main(){
cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
int n;
long long x;
cin >> n >> x;
long long tot = 0;
for(int i = 0; i < n; ++i){
cin >> arr[i];
tot += max(0, arr[i] - x);
arr[i] = min(x, arr[i]);
}
for(int i = 1; i < n; ++i){
if(arr[i - 1] + arr[i] > x){
long long dec = arr[i - 1] + arr[i] - x;
arr[i] -= dec;
tot += dec;
}
}
cout << tot;
return 0;
}
| a.cc: In function 'int main()':
a.cc:25:19: error: no matching function for call to 'max(int, long long int)'
25 | tot += max(0, arr[i] - x);
| ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:25:19: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
25 | tot += max(0, arr[i] - x);
| ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:25:19: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
25 | tot += max(0, arr[i] - x);
| ~~~^~~~~~~~~~~~~~~
|
s257783155 | p03862 | C++ | #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1000003 ;
int main(){
int n,x;
cin >> n >> x;
int a[n];
rep(i,n)cin >> a[i];
ll ans=0;
ll temp=a[0];
rep(i,n-1){
int res=temp+a[i+1]-x;
ans+=max(0,res);
temp=max(0,x-temp);
}
cout << ans << endl;
return 0;} | a.cc: In function 'int main()':
a.cc:34:13: error: no matching function for call to 'max(int, ll)'
34 | temp=max(0,x-temp);
| ~~~^~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:34:13: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
34 | temp=max(0,x-temp);
| ~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:3:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:34:13: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
34 | temp=max(0,x-temp);
| ~~~^~~~~~~~~~
|
s939262794 | p03862 | C++ | #include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll N,x,pre,A,ans;
int main(){
cin>>N>>x;
rep(i,N){
cin>>A;
if(i){
if(pre+A>x){
ans+=pre+A-x;
pre=max(x-pre,0);
}
else pre=A;
}
else pre=A;
}
out(ans);
}
| a.cc: In function 'int main()':
a.cc:31:28: error: no matching function for call to 'max(ll, int)'
31 | pre=max(x-pre,0);
| ~~~^~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:3:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:31:28: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
31 | pre=max(x-pre,0);
| ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:5:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:31:28: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
31 | pre=max(x-pre,0);
| ~~~^~~~~~~~~
|
s093373948 | p03862 | C++ | #include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll N,x,pre,A,ans;
int main(){
cin>>N>>x;
rep(i,N){
cin>>A;
if(i){
if(pre+A>x){
ans+=pre+A-x;
pre=max(x-pre,0);
}
else pre=A;
}
else pre=A;
}
out(ans);
}
| a.cc: In function 'int main()':
a.cc:31:28: error: no matching function for call to 'max(ll, int)'
31 | pre=max(x-pre,0);
| ~~~^~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:3:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:31:28: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
31 | pre=max(x-pre,0);
| ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:5:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:31:28: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
31 | pre=max(x-pre,0);
| ~~~^~~~~~~~~
|
s689486834 | p03862 | C++ | import java.util.*;
import java.lang.*;
public class Main{
public static void main(String[] args)
{
Scanner scanner=new Scanner(System.in);
int n=scanner.nextInt();
int x=scanner.nextInt();
int[] a=new int[n];
for(int i=0;i<n;i++)a[i]=scanner.nextInt();
int cnt=0;
for(int i=0;i<n-2;i++)
{
while((a[i]+a[i+1])>x){
if((a[i+1]+a[i+2])>x){
{if(a[i+1]>0){a[i+1]--;cnt++;}else {a[i]--;cnt++;}}}
else {
if(a[i]>0){a[i]--;cnt++;}
else {a[i+1]--;cnt++;}
}
}
}
if(a[n-2]+a[n-1]>x)cnt+=a[n-1]+a[n-2]-x;
System.out.print(cnt);
}
}
| a.cc:1:1: error: 'import' does not name a type
1 | import java.util.*;
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
2 | import java.lang.*;
| ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
3 | public class Main{
| ^~~~~~
|
s396381271 | p03862 | C++ | #include <iostream>
#include <math.h>
using namespace std;
typedef long long int ll;
int main() {
ll N, x, a1, a2, ans = 0;
cin >> N >> x >> a1;
for(ll i = 1; i < N; i++) {
cin >> a2;
ll sum = a1 + a2;
if(sum > x) {
ans += sum - x;
a1 = max(0ll, b - sum - x);
} else {
a1 = a2;
}
}
cout << ans;
return 0;
} | a.cc: In function 'int main()':
a.cc:13:27: error: 'b' was not declared in this scope
13 | a1 = max(0ll, b - sum - x);
| ^
|
s203741713 | p03862 | C++ | #include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N, x;
cin >> N >> x;
vector<int> a(N);
REP(i, N) cin >> a[i];
int ans = 0;
//まず左端
while(a[0] + a[1] > x) {
if(a[1] >= 0) {
a[1]--;
ans++;
} else {
a[0]--;
ans++;
}
}
//つぎに右端
while(a[N - 1] + a[N - 2] > x) {
if(a[N - 2] >= 0) {
a[N - 2]--;
ans++;
} else {
a[N - 1]--;
ans++;
}
}
for(int i = 0; i < N - 1; i++) {
while(a[i] + a[i + 1] > x) {
if(a[i + 1] >= 0) {
a[i + 1]--;
ans++;
} else {
a[i]--;
ans++;
}
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:46:4: error: expected '}' at end of input
46 | }
| ^
a.cc:6:12: note: to match this '{'
6 | int main() {
| ^
|
s847851879 | p03862 | C++ | #include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n,x,a[100000],ans;
int32_t main(){
CODE_START;
cin >> n;
cin >> x;
for(ll i=0;i<n;i++)
cin >> a[i];
for(ll i=1;i<n;i++)
if(a[i]+a[i-1]>x){
ans=ans+a[i]+a[i-1]-x;
a[i]=max(0LL,a[i]-a[i]-a[i-1]+x);
}
cout < <ans;
return 0;}
| a.cc: In function 'int32_t main()':
a.cc:33:8: error: expected primary-expression before '<' token
33 | cout < <ans;
| ^
|
s323000822 | p03862 | C++ | #include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()
ll gcd(ll a, ll b){
return b == 0 ? a : gcd(b, a % b);
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n, x;
cin >> n >> x;
ll ans = 0;
ll pre, cur;
cin >> pre;
REP(i, n-1) {
cin >> cur;
ll diff = (pre + tmp) - x;
if(diff > 0) {
ans += diff;
cur -= min(cur, diff);
}
pre = cur;
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:34:22: error: 'tmp' was not declared in this scope; did you mean 'tm'?
34 | ll diff = (pre + tmp) - x;
| ^~~
| tm
|
s606363572 | p03862 | C++ | #include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<stdio.h>
using namespace std;
typedef long long ll;
ll mod = 998244353;
int main(){
int N;
cin>>N;
vector<ll> A(N);
vector<ll> B(N, 0);
ll x;
cin>>x;
cin>>A[0];
B[0] = A[0];
for(int i = 1; i < N; i++){
cin>>A[i];
B[i] = B[i - 1] + A[i];
}
ll cnt = 0;
ll st = 0;
st = A[0];
ll em = 0;
//cout<<st<<endl;
for(ll i = 1; i < N; i++){
em = 0;
st += A[i];
if(st > x){
A[i] -= st - x;
A[i] < 0)em = abs(A[i]);
cnt += st - x;
cnt -= em;
st -= st - x;
st += em;
}
st -= A[i - 1];
}
cout<<cnt<<endl;
} | a.cc: In function 'int main()':
a.cc:36:33: error: expected ';' before ')' token
36 | A[i] < 0)em = abs(A[i]);
| ^
| ;
|
s118566091 | p03862 | C++ | #include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;
int main()
{
ll n, x;
cin >> n >> x;
ll a[n];
cin >> a[0];
for (int i = 1; i < n; i++) {
ll count = 0;
cin >> a[i];
if (a[i] + a[i - 1] > x) {
count += min(a[i], a[i] + a[i - 1] - x);
a[i] -= count;
}
if (a[i] + a[i - 1] > x) count += a[i] + a[i - 1] - x;
ans += count;
}
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:29:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
29 | ans += count;
| ^~~
| abs
a.cc:31:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
31 | cout << ans << endl;
| ^~~
| abs
|
s286119261 | p03862 | C++ | #include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;
int main()
{
ll n, x;
cin >> n >> x;
ll a[n];
cin >> a[0];
for (int i = 1; i < n; i++) {
ll count = 0;
cin >> a[i];
if (a[i] + a[i - 1] > x) {
count += min(a[i], a[i] + a[i - 1] - x);
a[i] -= count;
}
if (a[i] + a[i - 1] > x) count += a[i] + a[i - 1] - x;
ans += count;
}
cout << count << endl;
}
| a.cc: In function 'int main()':
a.cc:29:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
29 | ans += count;
| ^~~
| abs
a.cc:31:8: error: no match for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and '<unresolved overloaded function type>')
31 | cout << count << endl;
| ~~~~~^~~~~~~~
In file included from /usr/include/c++/14/iostream:41,
from a.cc:4:
/usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'}
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]'
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ^~~~~~~~
/usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::ios_base& (*)(std::ios_base&)'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
174 | operator<<(long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long int'
174 | operator<<(long __n)
| ~~~~~^~~
/usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
178 | operator<<(unsigned long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long unsigned int'
178 | operator<<(unsigned long __n)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
182 | operator<<(bool __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'bool'
182 | operator<<(bool __n)
| ~~~~~^~~
In file included from /usr/include/c++/14/ostream:1022:
/usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]'
96 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short int'
97 | operator<<(short __n)
| ~~~~~~^~~
/usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
189 | operator<<(unsigned short __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short unsigned int'
189 | operator<<(unsigned short __n)
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]'
110 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int'
111 | operator<<(int __n)
| ~~~~^~~
/usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
200 | operator<<(unsigned int __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'unsigned int'
200 | operator<<(unsigned int __n)
| ~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
211 | operator<<(long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int'
211 | operator<<(long long __n)
| ~~~~~~~~~~^~~
/usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
215 | operator<<(unsigned long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long unsigned int'
215 | operator<<(unsigned long long __n)
| ~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
231 | operator<<(double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'double'
231 | operator<<(double __f)
| ~~~~~~~^~~
/usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
235 | operator<<(float __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'float'
235 | operator<<(float __f)
| ~~~~~~^~~
/usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
243 | operator<<(long double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long double'
243 | operator<<(long double __f)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
301 | operator<<(const void* __p)
| ^~~~~~~~
/usr/include/c++/14/ostream:301:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const void*'
301 | operator<<(const void* __p)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:306:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::nullptr_t) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; std::nullptr_t = std::nullptr_t]'
306 | operator<<(nullptr_t)
| ^~~~~~~~
/usr/include/c++/14/ostream:306:18: note: n |
s674520049 | p03862 | Java | import java.util.*;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int x = sc.nextInt();
int[] a = new int[N];
for(int i = 0; i<N; i++) {
a[i] = sc.nextInt();
}
long ans = 0;
for(int i = 1; i<N; i++) {
long sum = a[i]+a[i-1];
if(sum>x) {
ans += sum-x;
a[i] = Math.max(0, a[i]-sum);
}
}
System.out.println(ans);
}
} | Main.java:16: error: incompatible types: possible lossy conversion from long to int
a[i] = Math.max(0, a[i]-sum);
^
1 error
|
s813053809 | p03862 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int n;
ll x;
cin >> n >> x;
ll ans = 0;
ll a[100010];
for(int i = 0; i < n; i++)
{
cin >> a[i];
}
for(int i = 0; i < n-1; i++)
{
if(i==0) ans+= max(0, a[i]-x);
if(a[i]+a[i+1]>x){
ans += a[i+1]+a[i]-x;
a[i+1] = x-a[i];
}
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:19:27: error: no matching function for call to 'max(int, ll)'
19 | if(i==0) ans+= max(0, a[i]-x);
| ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:19:27: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
19 | if(i==0) ans+= max(0, a[i]-x);
| ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:19:27: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
19 | if(i==0) ans+= max(0, a[i]-x);
| ~~~^~~~~~~~~~~
|
s762009894 | p03862 | C++ | #include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,x;
cin>>n>>x;
vector<ll> a(n);
REP(i,n) cin>>a[i];
ll ans=0;
REP(i,n-1){
while(a[i]+a[i+1]>x){
ll minus = max(a[i]+a[i+1] - x,0);
a[i+1] -= minus;
ans+=minus;
}
}
cout<<ans<<endl;
} | a.cc: In function 'int main()':
a.cc:37:27: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type, int)'
37 | ll minus = max(a[i]+a[i+1] - x,0);
| ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:37:27: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
37 | ll minus = max(a[i]+a[i+1] - x,0);
| ~~~^~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:37:27: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
37 | ll minus = max(a[i]+a[i+1] - x,0);
| ~~~^~~~~~~~~~~~~~~~~~~
|
s937251698 | p03862 | C++ | #include <cstdio>
#include<iostream>
using namespace std;
int box[100005];
int main()
{
int n,x;
scanf("%d%d",&n,&x);
for (int i=1;i<=n;i++)
scanf("%d",&box[i]);
long long all=0;
if (box[1]>x)
{
all+=box[1]-x;
box[1]=x;
}
for (int i=2;i<=n;i++)
{
int k = box[i]+box[i-1]-x;
if (k>0)
{
all+=k;
box[i]-=k;
}
}
cout<<all;
} | a.cc: In function 'int main()':
a.cc:9:24: error: expected ';' before '\U0000ff1b'
9 | scanf("%d%d",&n,&x);
| ^~
| ;
a.cc:11:22: error: 'i' was not declared in this scope
11 | for (int i=1;i<=n;i++)
| ^
|
s056006590 | p03862 | C++ | #include <iostream>
#include <vector>
#define vrev(v) reverse((v).begin(), (v).end())
using namespace std;
using ll = long long;
int main(int argc, const char * argv[]) {
ll n, x;
cin >> n >> x;
vector<ll> v1(n), v2(n);
for (ll i = 0; i < n; i++) {
cin >> v1[i];
v2[i] = v1[i];
}
ll cnt = 0;
for (ll i = 0; i < n - 1; i++) {
if (v1[i] + v1[i+1] > x) {
cnt += v1[i] + v1[i+1] - x;
v1[i+1] -= v1[i] + v1[i+1] - x;
}
}
ll ans = cnt;
vrev(v2);
for (ll i = 0; i < n - 1; i++) {
if (v2[i] + v2[i+1] > x) {
cnt += v2[i] + v2[i+1] - x;
v2[i+1] -= v2[i] + v2[i+1] - x;
}
}
ans = min(ans, cnt);
cout << cnt << endl;
}
| a.cc: In function 'int main(int, const char**)':
a.cc:4:17: error: 'reverse' was not declared in this scope
4 | #define vrev(v) reverse((v).begin(), (v).end())
| ^~~~~~~
a.cc:26:5: note: in expansion of macro 'vrev'
26 | vrev(v2);
| ^~~~
|
s142478641 | p03862 | C++ | #include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1000000000
#define mod 1000000007
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
ll N,X,ans=0;
cin>>N>>X;
VI a(N);
REP(i,N){
cin>>a[i];
if(a[i]>X){
ans+=a[i]-X;
a[i]=X;
if(a[i]+a[i-1]>X && i-1>=0){
ans+=a[i]+a[i-1]-X;
a[i]-=a[i]+a[i-1]-X;
}
}
cout<<ans<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:34:2: error: expected '}' at end of input
34 | }
| ^
a.cc:15:11: note: to match this '{'
15 | int main(){
| ^
|
s470163775 | p03862 | Java | import java.util.Scanner;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int number = sc.nextInt();
long max = sc.nextLong();
int count = 0;
long[] c = new long[number];
for(int i = 0; i < number; i++){
long a = sc.nextLong();
c[i]=a;
}
for(int i = 1; i < number; i++){
if(c[i-1]+c[i]>max){
if(((a[i-1]+a[i])-x) < a[i]){
count += c[i-1]+c[i]-max;
c[i]=max-c[i-1];
}else{
count += c[i]-max+c[i-1];
c[i]=0;
}
}
}
System.out.println(count);
}
} | Main.java:15: error: cannot find symbol
if(((a[i-1]+a[i])-x) < a[i]){
^
symbol: variable a
location: class Main
Main.java:15: error: cannot find symbol
if(((a[i-1]+a[i])-x) < a[i]){
^
symbol: variable a
location: class Main
Main.java:15: error: cannot find symbol
if(((a[i-1]+a[i])-x) < a[i]){
^
symbol: variable x
location: class Main
Main.java:15: error: cannot find symbol
if(((a[i-1]+a[i])-x) < a[i]){
^
symbol: variable a
location: class Main
4 errors
|
s519338327 | p03862 | C++ | 3 3
2 2 2 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 3 3
| ^
|
s971687427 | p03862 | C++ | #include < bits / stdc++.h >
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)
const ll MOD = 1000000007;
const ll INF = (ll)1e15;
ll A[100005];
int main()
{
int N, x;
cin >> N >> x;
REP(i, N)
{
cin >> A[i];
}
ll n = 0;
FOR(i, N, 1)
{
if (A[i] + A[i - 1] <= x)
continue;
int t = x - (A[i] + A[i - 1]);
n += t;
A[i] -= std::min(t, A[i]);
}
cout << n << endl;
return 0;
} | a.cc:1:10: fatal error: bits / stdc++.h : No such file or directory
1 | #include < bits / stdc++.h >
| ^~~~~~~~~~~~~~~~~~~
compilation terminated.
|
s720300795 | p03862 | C++ | #inclde < bits / stdc++.h >
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pll;
#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)
const ll MOD = 1000000007;
const ll INF = (ll)1e15;
ll A[100005];
int main()
{
int N, x;
cin >> N >> x;
REP(i, N)
{
cin >> A[i];
}
ll n = 0;
FOR(i, N, 1)
{
if (A[i] + A[i - 1] <= x)
continue;
int t = x - (A[i] + A[i - 1]);
n += t;
A[i] -= std::min(t, A[i]);
}
cout << n << endl;
return 0;
} | a.cc:1:2: error: invalid preprocessing directive #inclde; did you mean #include?
1 | #inclde < bits / stdc++.h >
| ^~~~~~
| include
a.cc:5:9: error: 'pair' does not name a type
5 | typedef pair<ll, ll> pll;
| ^~~~
a.cc: In function 'int main()':
a.cc:19:5: error: 'cin' was not declared in this scope
19 | cin >> N >> x;
| ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
+++ |+#include <iostream>
1 | #inclde < bits / stdc++.h >
a.cc:33:22: error: 'min' is not a member of 'std'
33 | A[i] -= std::min(t, A[i]);
| ^~~
a.cc:35:5: error: 'cout' was not declared in this scope
35 | cout << n << endl;
| ^~~~
a.cc:35:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:35:18: error: 'endl' was not declared in this scope
35 | cout << n << endl;
| ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
+++ |+#include <ostream>
1 | #inclde < bits / stdc++.h >
|
s717591499 | p03862 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
long long n, x;
cin >> n >> x;
vector<long long> a(n);
for(int i = 0; i < n; i++) {
cin >> a[i];
}
int cnt = 0;
for(int i = 1; i < n; i++) {
long long adj = a[i] + a[i - 1];
if(adj > x) {
cnt += adj - x;
a[i] = max(a[i] - (adj - x), 0);
}
}
cout << cnt << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:19:35: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type, int)'
19 | a[i] = max(a[i] - (adj - x), 0);
| ~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:19:35: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
19 | a[i] = max(a[i] - (adj - x), 0);
| ~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:19:35: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
19 | a[i] = max(a[i] - (adj - x), 0);
| ~~~^~~~~~~~~~~~~~~~~~~~~
|
s846377251 | p03862 | C++ | #include<iostream>
using namespace std;
int main(){
int n,x;
int c=0;
cin>>n>>x;
int arr[n];
for(int i=0;i<n;i++)cin>>arr[i];
if(arr[0]>x){
c = arr[0]-x;
arr[0]=x;
}
for(int i==1; i <n; i++){
int a;
a = arr[i] + arr[i-1];
if(a > x){
c+=a-x;
arr[i] =a-x;
}
}
} | a.cc: In function 'int main()':
a.cc:13:12: error: expected ';' before '==' token
13 | for(int i==1; i <n; i++){
| ^~
| ;
a.cc:13:12: error: expected primary-expression before '==' token
13 | for(int i==1; i <n; i++){
| ^~
a.cc:13:21: error: expected ')' before ';' token
13 | for(int i==1; i <n; i++){
| ~ ^
| )
a.cc:13:23: error: 'i' was not declared in this scope
13 | for(int i==1; i <n; i++){
| ^
|
s008751644 | p03862 | C++ | /**
* @Author : MeGaCrazy
* @InitTime : Sun Dec 30 14:56:45 2018
* @Idea :
*
*
*
*
*
* Happy Solving :)
**/
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+7;
long long a[N];
int main(){
#ifndef ONLINE_JUDGE
// freopen("in","r",stdin);
//freopen("out","w",stdout);
#endif
long long n,m;
scanf("%lld %lld",&n,&m);
for(int i=0;i<n;i++){
scanf("%lld",&a[i]);
}
long long ans=0;
for(int i=0;i+1<n;i++){
long long cur=a[i]+a[i+1];
if(cur>m){
long long dif=cur-m;
a[i+1]=max(0,a[i+1]-dif);
ans+=dif;
}
}
printf("%lld",ans);
} | a.cc: In function 'int main()':
a.cc:32:24: error: no matching function for call to 'max(int, long long int)'
32 | a[i+1]=max(0,a[i+1]-dif);
| ~~~^~~~~~~~~~~~~~
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:12:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:32:24: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
32 | a[i+1]=max(0,a[i+1]-dif);
| ~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:32:24: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
32 | a[i+1]=max(0,a[i+1]-dif);
| ~~~^~~~~~~~~~~~~~
|
s007438306 | p03862 | C++ | #include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;
int main() {
int n, x;
cin >> n >> x;
ll c_all = 0;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a.at(i);
c_all += a.at(i);
}
if (a.at(0) > x) a.at(0) = x;
for (int i = 0; i < n - 1; i++) {
if (a.at(i) + a.at(i + 1) > x) {
int tmp += a.at(i) + a.at(i + 1) - x;
a.at(i + 1) -= tmp;
}
}
ll c_min = accumulate(a.begin(), a.end(), 0);
cout << c_all - c_min << endl;
}
| a.cc: In function 'int main()':
a.cc:18:15: error: expected initializer before '+=' token
18 | int tmp += a.at(i) + a.at(i + 1) - x;
| ^~
a.cc:19:22: error: 'tmp' was not declared in this scope; did you mean 'tm'?
19 | a.at(i + 1) -= tmp;
| ^~~
| tm
|
s141394762 | p03862 | C++ | #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <typeinfo>
using namespace std;
int main(){
int N;
long long x;
cin >> N >> x;
vector<long long> a(N);
for(int i=0;i<N;i++) cin >> a.at(i);
long long ans=0;
for(int i=1;i<N;i++){
long long b=a.at(i-1)+a.at(i);
ans+=max(0,b-x);
a.at(i)-=max(0,b-x);
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:27:13: error: no matching function for call to 'max(int, long long int)'
27 | ans+=max(0,b-x);
| ~~~^~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:27:13: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
27 | ans+=max(0,b-x);
| ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:4:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:27:13: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
27 | ans+=max(0,b-x);
| ~~~^~~~~~~
a.cc:28:17: error: no matching function for call to 'max(int, long long int)'
28 | a.at(i)-=max(0,b-x);
| ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:28:17: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
28 | a.at(i)-=max(0,b-x);
| ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:28:17: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
28 | a.at(i)-=max(0,b-x);
| ~~~^~~~~~~
|
s438821165 | p03862 | C++ | # include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int main()
{
optimize_cin();
lint N; cin >> N;
lint x; cin >> x;
vector<lint> a(N);
rep (i, N) { cin >> a[i]; }
lint cnt = 0;
rep (lint i = 0; i < N - 1; ++i)
{
if (a[i]+a[i+1] > x)
{
if (a[i] > a[i+1])
{
cnt += a[i] - (x - a[i+1]);
a[i] = x - a[i+1];
}
else
{
cnt += a[i+1] - (x - a[i]);
a[i+1] = x - a[i];
}
}
}
cout << cnt << "\n";
return 0;
}
| a.cc:26:36: error: macro "rep" requires 2 arguments, but only 1 given
26 | rep (lint i = 0; i < N - 1; ++i)
| ^
a.cc:2:10: note: macro "rep" defined here
2 | # define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
| ^~~
a.cc: In function 'int main()':
a.cc:26:5: error: 'rep' was not declared in this scope
26 | rep (lint i = 0; i < N - 1; ++i)
| ^~~
|
s635314408 | p03862 | C++ | #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using lli = long long int;
ll MM = 1000000000;
ll mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
int main(){
ll n, x, a[100001];
cin >> n >> x;
ll cnt = 0;
for(ll i = 0; i < n; i++){
cin >> a[i];
}
if(a[0] > x){
cnt += a[0] -x;
a[0] = x;
}
for(ll i = 1; i < n; i++{
if(a[i-1] + a[i] > x){
cnt += a[i-1] + a[i] -x;
a[i] = x - a[i-1];
}
}
cout << cnt << endl;
} | a.cc: In function 'int main()':
a.cc:21:29: error: expected ')' before '{' token
21 | for(ll i = 1; i < n; i++{
| ~ ^
| )
|
s364207136 | p03862 | C++ | #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using lli = long long int;
ll MM = 1000000000;
ll mod = MM + 7;
#define INF (ll)1e18
#define pi acos(-1.0)
int main(){
ll n, x, a[100001];
cin >> n >> x;
ll cnt = 0;
for(ll i = 0; i < n; i++){
cin >> a[i];
}
if(a[0] > x){
cnt += a[i] -x;
a[i] = x;
}
for(ll i = 1; i < n; i++{
if(a[i-1] + a[i] > x){
cnt += a[i-1] + a[i] -x;
a[i] = x - a[i-1];
}
}
cout << cnt << endl;
} | a.cc: In function 'int main()':
a.cc:18:18: error: 'i' was not declared in this scope
18 | cnt += a[i] -x;
| ^
a.cc:21:29: error: expected ')' before '{' token
21 | for(ll i = 1; i < n; i++{
| ~ ^
| )
|
s296209198 | p03862 | C++ | #include <bits/stdc++.h>
using namespace std;
int main () {
int N;
long x;
cin >> N >> x;
vector<long> a(N);
for (int i = 0; i < N; i++) {
cin >> a.at(i);
}
long ans = 0;
for (int i = 0; i < N-1; i++) {
if (a.at(i) + a.at(i+1) > x) {
long p = a.at(i) + a.at(i+1) -x;
ans += p;
a.at(i+1) = max(0, a.at(i+1)-p);
}
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:17:22: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type)'
17 | a.at(i+1) = max(0, a.at(i+1)-p);
| ~~~^~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:17:22: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type' {aka 'long int'})
17 | a.at(i+1) = max(0, a.at(i+1)-p);
| ~~~^~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:17:22: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
17 | a.at(i+1) = max(0, a.at(i+1)-p);
| ~~~^~~~~~~~~~~~~~~~
|
s037389057 | p03862 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
int N,K,res=0;
cin>>N>>K;
vector<int> a(N,0);
for(int c,i=0;i<N;++i){
cin>>c;
if(i<N-1)a[i]+=c;
if(i>0)a[i-1]+=c;
}
for(int i=1;i<N;++i){
int c=max(0,a[i-1]-K);
c=max(0,a[i]-c)
a[i]-=c; a[i-1]-=c; res+=c;
/*do{
if(a[i]<=0 || a[i-1]-K<=0)break;
--a[i]; --a[i-1]; ++res;
}while(true);*/
}
for(int i=0;i<N-1;++i)res+=max(0,a[i]-K);
cout<<res;
return 0;
}
| a.cc: In function 'int main()':
a.cc:14:20: error: expected ';' before 'a'
14 | c=max(0,a[i]-c)
| ^
| ;
15 | a[i]-=c; a[i-1]-=c; res+=c;
| ~
|
s684030888 | p03862 | C++ | #include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int MAX_N = (int) 1e5;
ll N, x;
ll a[MAX_N];
void solve() {
ll ans = 0;
if (a[0] > x) {
a[0] = x;
ans += (a[0] - x);
}
REP(i, N - 1) {
if (a[i] + a[i + 1] > x) {
ll temp = min(a[i + 1], a[i] + a[i + 1] - x));
a[i + 1] -= temp;
ans += temp;
}
}
cout << ans << endl;
}
int main() {
cin >> N >> x;
REP(i, N) cin >> a[i];
solve();
return 0;
} | a.cc: In function 'void solve()':
a.cc:34:57: error: expected ',' or ';' before ')' token
34 | ll temp = min(a[i + 1], a[i] + a[i + 1] - x));
| ^
|
s008026935 | p03862 | C++ | #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(v) for (int i = 0; i < v.size(); i++)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;
int a[111111];
int main()
{
int n, x;
ll ans = 0;
cin>>n>>x;
REP(i,n) {
cin>>a[i];
//a2[i] = a[i];
}
for (int i = 0; i < n-1; i++) {
int tmp = a[i] + a[i+1];
if (tmp > x) {
ans += tmp - x;
a[i+1] -= min(ans, a[i+1]);
}
}
cout<<ans<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:33:20: error: no matching function for call to 'min(ll&, int&)'
33 | a[i+1] -= min(ans, a[i+1]);
| ~~~^~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:33:20: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
33 | a[i+1] -= min(ans, a[i+1]);
| ~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:33:20: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
33 | a[i+1] -= min(ans, a[i+1]);
| ~~~^~~~~~~~~~~~~
|
s635296340 | p03862 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll N, X;
cin >> N >> X;
ll A[100000];
rep(i, N) cin >> A[i];
ll kotae = 0;
rep(i, N - 1) {
ll herasu = max(0, A[i] + A[i + 1] - X);
kotae += herasu;
if (herasu > 0) {
if (A[i + 1] >= herasu) A[i + 1] -= herasu;
else { A[i + 1] = 0; }
}
}
co(kotae);
Would you please return 0;
} | a.cc: In function 'int main()':
a.cc:29:32: error: no matching function for call to 'max(int, ll)'
29 | ll herasu = max(0, A[i] + A[i + 1] - X);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:29:32: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
29 | ll herasu = max(0, A[i] + A[i + 1] - X);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:29:32: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
29 | ll herasu = max(0, A[i] + A[i + 1] - X);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~
|
s427897959 | p03862 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int N,x;
cin >> N >> x;
vector<int> a(100010);
for(int i=0;i<N;i++){cin >> a[i];}
int c=0; int d=0;
for(int i=1;i<N;i++){
if(a[i-1]+a[i]>x){
c+=a[i-1]+a[i]-x;
a[i]-=a[i-1]+a[i]-x;
}
}
for(int i=N-2;i>=0;i--){
if(a[i+1]+a[i]>x){
d+=a[i+1]+a[i]-x;
a[i]-=a[i+1]+a[i]-x;
}
cout << min(c,d) << endl;
} | a.cc: In function 'int main()':
a.cc:22:2: error: expected '}' at end of input
22 | }
| ^
a.cc:4:12: note: to match this '{'
4 | int main() {
| ^
|
s061135617 | p03862 | C++ | #include<bits/stdc++.h>
using namespace std;
long long a[100002];
int main(){
long long n,x,ans=0;
cin>>n>>x;
for(int i=1;i<=n;i++) cin>>a[i];
for(int i=2;i<=n;i++){
if(a[i]+a[i-1]>x){
ans+=(a[i-1]+a[i])-x;
if(a[i-1]>x){
a[i]=0;
a[i-1]-=a[i-1]-x
}else{
a[i]-=((a[i-1]+a[i])-x);
}
}
}
cout<<ans;
return 0;
}
| a.cc: In function 'int main()':
a.cc:13:49: error: expected ';' before '}' token
13 | a[i-1]-=a[i-1]-x
| ^
| ;
14 | }else{
| ~
|
s234935458 | p03862 | C++ | #include<bits/stdc++.h>
using namespace std;
int main()
{
int n,m,ans,s;
cin>>n>>m;
for(int i=0;i<=n;i++)cin>>s[i];
for(int i=0;i<n;i++)
{
if(s[i]+s[i+1]>m)
{
ans+=s[i+1]+s[i]-m;
s[i]-m;
}
}
cout<<ans;
return 0;
}
| a.cc: In function 'int main()':
a.cc:7:36: error: invalid types 'int[int]' for array subscript
7 | for(int i=0;i<=n;i++)cin>>s[i];
| ^
a.cc:10:21: error: invalid types 'int[int]' for array subscript
10 | if(s[i]+s[i+1]>m)
| ^
a.cc:10:26: error: invalid types 'int[int]' for array subscript
10 | if(s[i]+s[i+1]>m)
| ^
a.cc:12:31: error: invalid types 'int[int]' for array subscript
12 | ans+=s[i+1]+s[i]-m;
| ^
a.cc:12:38: error: invalid types 'int[int]' for array subscript
12 | ans+=s[i+1]+s[i]-m;
| ^
a.cc:13:26: error: invalid types 'int[int]' for array subscript
13 | s[i]-m;
| ^
|
s127422829 | p03862 | C++ | #include<bits/stdc++.h>
using namespace std;
int a[101];
int main(){
int n,i,j,x,sum=0;
cin>>n>>x;
for(i=1;i<=n;i++)
cin>>a[i];
for(i=1;i<n;i++)
for(j=2;j<=n;j++)
if(a[j]-a[i]>xa[i]-a[j]>x) sum++;
cout<<sum;
return 0;
} | a.cc: In function 'int main()':
a.cc:11:38: error: 'xa' was not declared in this scope; did you mean 'x'?
11 | if(a[j]-a[i]>xa[i]-a[j]>x) sum++;
| ^~
| x
|
s036861526 | p03862 | C++ | C - Boxes and Candies
| a.cc:1:1: error: 'C' does not name a type
1 | C - Boxes and Candies
| ^
|
s241849844 | p03862 | C++ | #include<bits/stdc++.h>
using namespace std;
int a[101]
int main(){
int n,i,j,x,sum=0;
cin>>n>>x;
for(i=1;i<=n;i++)
cin>>a[i];
for(i=1;i<n;i++)
for(j=2;j<=n;j++)
if(a[j]-a[i]>xa[i]-a[j]>x) sum++;
cout<<sum;
return 0;
} | a.cc:4:1: error: expected initializer before 'int'
4 | int main(){
| ^~~
|
s812800730 | p03862 | C++ | #include<bits/stdc++.h>
using namespace std;
int a[101]
int main(){
int n,i,j,xsum=0;
cin>>n>>x;
for(i=1;i<=n;i++)
cin>>a[i];
for(i=1;i<n;i++)
for(j=2;j<=n;j++)
if(a[j]-a[i]>xa[i]-a[j]>x) sum++;
cout<<sum;
return 0;
}
| a.cc:4:1: error: expected initializer before 'int'
4 | int main(){
| ^~~
|
s425527008 | p03862 | C++ | #include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#include<deque>
#define rep(i,rept) for(int i = 0; i<(int)rept;++i)
typedef long long ll;
const ll MOD = 1e9 + 7;
using namespace std;
int main() {
//12日目-1
cin.tie(0); ios::sync_with_stdio(false);
int n = 0, x = 0, a[100000] = {};
ll ans = 0;
cin >> n >> x;
rep(i, n) {
cin >> a[i];
if (a[i] > x) {
ans += a[i] - x;
a[i] = x;
}
}
for (int i = 0; i + 1 < n; i++) {
if (a[i] + a[i + 1] > x) {
ans += (a[i + 1] + a[i]) - x;
a[i + 1] -= (a[i] + a[i + 1]) - x;
}
}
cout << ans << endl;
return 0;
}
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#include<deque>
#define rep(i,rept) for(int i = 0; i<(int)rept;++i)
typedef long long ll;
const ll MOD = 1e9 + 7;
using namespace std;
int main() {
//12日目-1
cin.tie(0); ios::sync_with_stdio(false);
int n = 0, x = 0, a[100000] = {};
ll ans = 0;
cin >> n >> x;
rep(i, n) {
cin >> a[i];
if (a[i] > x) {
ans += a[i] - x;
a[i] = x;
}
}
for (int i = 0; i + 1 < n; i++) {
if (a[i] + a[i + 1] > x) {
ans += (a[i + 1] + a[i]) - x;
a[i + 1] -= (a[i] + a[i + 1]) - x;
}
}
cout << ans << endl;
return 0;
} | a.cc:59:10: error: redefinition of 'const ll MOD'
59 | const ll MOD = 1e9 + 7;
| ^~~
a.cc:16:10: note: 'const ll MOD' previously defined here
16 | const ll MOD = 1e9 + 7;
| ^~~
a.cc:62:5: error: redefinition of 'int main()'
62 | int main() {
| ^~~~
a.cc:19:5: note: 'int main()' previously defined here
19 | int main() {
| ^~~~
|
s407178716 | p03862 | C++ | #include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)
typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;
constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
int main() {
int N,x; cin>>N>>x;
int a[N]; REP(i,N) cin>>a[i];
i64 ans=0;
REP(i,N-1) {
i64 d = a[i]+a[i+1]-x;
if (d>0) {
ans += d;
if (d<a[i+1]) a[i+1] -= d;
else a[i+1] = 0
}
}
cout<<ans<<endl;
}
| a.cc: In function 'int main()':
a.cc:38:28: error: expected ';' before '}' token
38 | else a[i+1] = 0
| ^
| ;
39 | }
| ~
|
s891453682 | p03862 | C | #include<stdio.H>
int main(){
int n;
long a[100000],x,cnt=0;
scanf("%d %ld",&n,&x);
scanf("%ld",a[0]);
if(a[0]>x){
cnt+=a[0]-x;
a[0]=x;
}
for(int i=1;i<n;i++){
scanf("%ld",&a[i]);
if(a[i]+a[i-1]>x){
cnt+=a[i]+a[i-1]-x;
a[i]-=a[i]+a[i-1]-x;
}
}
printf("%ld\n",cnt);
} | main.c:1:9: fatal error: stdio.H: No such file or directory
1 | #include<stdio.H>
| ^~~~~~~~~
compilation terminated.
|
s521202775 | p03862 | C++ | #include <bits/stdc++.h>
typedef long long ll;
int main(int argc, char const *argv[]) {
ll N, x;
std::cin >> N >> x;
ll a[N];
for (size_t i = 0; i < N; i++) {
std::cin >> a[i];
}
ll count = 0;
for (size_t i = 0; i < N - 1; i++) {
if (a[i] + a[i + 1] > x) {
count += a[i] + a[i + 1] - x;
if (x >= a[i]) {
a[i + 1] = x - a[i];
} else {
a[i + 1] = 0;
a[i] = x;
}
}
}
std::cout << count << '\n';
return 0;
}
#include <bits/stdc++.h>
typedef long long ll;
int main(int argc, char const *argv[]) {
ll N, x;
std::cin >> N >> x;
ll a[N];
for (size_t i = 0; i < N; i++) {
std::cin >> a[i];
}
ll count = 0;
for (size_t i = 0; i < N - 1; i++) {
if (a[i] + a[i + 1] > x) {
count += a[i] + a[i + 1] - x;
if (x >= a[i]) {
a[i + 1] = x - a[i];
} else {
a[i + 1] = 0;
a[i] = x;
}
}
}
std::cout << count << '\n';
return 0;
}
| a.cc:30:5: error: redefinition of 'int main(int, const char**)'
30 | int main(int argc, char const *argv[]) {
| ^~~~
a.cc:4:5: note: 'int main(int, const char**)' previously defined here
4 | int main(int argc, char const *argv[]) {
| ^~~~
|
s947957295 | p03862 | C++ | #include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
int n,x;
int a[100000];
cin>>n>>x;
for(int i=0;i<n;i++){
cin>>a[i];
}
int ans=0;
for(int i=0;i<n-1;i++){
if(a[i]+a[i+1]>x){
ans+=a[i]+a[i+1]-x;
if(a[i]>x){
a[i+1]=0;
}else{
a[i+1]=x-a[i];
}
}
}
out<<ans<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:37:9: error: 'out' was not declared in this scope
37 | out<<ans<<endl;
| ^~~
|
s144396846 | p03862 | C++ | #include <iostream>
#include <cstdint>
#include <algorithm>
int main() {
std::int_fast64_t n, x;
std::cin >> n >> x;
std::vector<std::int_fast64_t> a(n);
for (std::int_fast64_t i = 0; i < n; ++i) {
std::cin >> a[i];
}
std::int_fast64_t result = 0;
for (std::int_fast64_t i = 1; i < n; ++i) {
const std::int_fast64_t right = std::max(static_cast<std::int_fast64_t>(0), std::min(a[i - 1] + a[i] - x, a[i]));
a[i] -= right;
const std::int_fast64_t left = std::max(static_cast<std::int_fast64_t>(0), std::min(a[i - 1] + a[i] - x, a[i - 1]));
a[i - 1] -= left;
result += left + right;
}
std::cout << result << std::endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:8:8: error: 'vector' is not a member of 'std'
8 | std::vector<std::int_fast64_t> a(n);
| ^~~~~~
a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
3 | #include <algorithm>
+++ |+#include <vector>
4 |
a.cc:8:32: error: expected primary-expression before '>' token
8 | std::vector<std::int_fast64_t> a(n);
| ^
a.cc:8:34: error: 'a' was not declared in this scope
8 | std::vector<std::int_fast64_t> a(n);
| ^
|
s790935853 | p03862 | C++ | N, x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
ans = 0
(N-1).times do |i|
tmp = a[i] + a[i+1] - x
if tmp > 0
a[i+1] -= tmp
ans += tmp
end
end
print ans, "\n"
| a.cc:1:1: error: 'N' does not name a type
1 | N, x = gets.split.map(&:to_i)
| ^
|
s602249246 | p03862 | C++ | #include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
//#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define huge 1000000007
typedef long long ll;
int main(void) {
ll N = 0;
ll A = 0;
ll B = 0;
ll K = 0;
ll Y = 0;
ll X = 0;
ll x[100000] = {};
//ll c[10000] = {};
//ll d[10000] = {};
//ll *x, *c, *d;
//string w;
ll count = 0;
ll sum = 0;
ll i = 0;
cin >> N >> X;
rep(i, 0, N) {
cin >> x[i];
}
if (x[0] > X) {
count += (x[0]) - X;
x[0] -= count;
}
rep(i, 0, N-1) {
if (x[i] + x[i + 1] > X) {
count += (x[i] + x[i + 1]) - X;
x[i + 1] -= count;
}
}
cout << count << endl;
return 0;
| a.cc: In function 'int main()':
a.cc:56:18: error: expected '}' at end of input
56 | return 0;
| ^
a.cc:18:16: note: to match this '{'
18 | int main(void) {
| ^
|
s792600545 | p03862 | C | #include <bits/stdc++.h>
using namespace std;
int num[100005];
int main()
{
int n,k;
scanf("%d%d",&n,&k);
int sum=0;
for(int i=0;i<n;i++)
{
scanf("%d",&num[i]);
if(i>=1)
{
if(num[i-1]<=num[i]&&num[i-1]+num[i]>k)
{
sum+=num[i]-k+num[i-1];
num[i]-=num[i]-k+num[i-1];
}
}
}
printf("%d\n",sum);
return 0;
} | main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
1 | #include <bits/stdc++.h>
| ^~~~~~~~~~~~~~~
compilation terminated.
|
s895673433 | p03862 | C++ | #include <bits/stdc++.h>
using namespace std;
/* define const */
/* end up defineing const */
long nnn = 0;
long a[1000000010];
long x = 0;
int main()
{
cin >> nnn >> x;
for (int i = 0; i < nnn; i++) cin >> a[i];
// end up inputting
long cnt = 0;
for (int i = 0; i < nnn-1; i++) {
if (a[i]+a[i+1] > x) {
long sub = (a[i+1]+a[i])-x;
if (a[i+1] >= sub) {
a[i+1] -= sub;
cnt += sub;
}
else {
a[i] = a[i] - sub + a[i+1];
a[i+1] = 0;
cnt += sub;
}
}
// for (int i = 0; i < nnn;i++) cout << a[i] << " ";
// cout << endl;
}
cout << cnt << endl;
} | /tmp/ccBE3E8J.o: in function `main':
a.cc:(.text+0x27): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/ccBE3E8J.o
a.cc:(.text+0xcb): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/ccBE3E8J.o
a.cc:(.text+0x111): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/ccBE3E8J.o
collect2: error: ld returned 1 exit status
|
s245147451 | p03862 | C++ | #include <bits/stdc++.h>
using namespace std;
/* define const */
/* end up defineing const */
long n = 0;
long a[1000000010];
long x = 0;
int main()
{
cin >> n >> x;
for (int i = 0; i < n; i++) cin >> a[i];
// end up inputting
long cnt = 0;
for (int i = 0; i < n-1; i++) {
if (a[i]+a[i+1] > x) {
long sub = (a[i+1]+a[i])-x;
if (a[i+1] >= sub) {
a[i+1] -= sub;
cnt += sub;
}
else {
a[i] = a[i] - sub + a[i+1];
a[i+1] = 0;
cnt += sub;
}
}
// for (int i = 0; i < n;i++) cout << a[i] << " ";
// cout << endl;
}
cout << cnt << endl;
} | /tmp/cc40wXH4.o: in function `main':
a.cc:(.text+0x27): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/cc40wXH4.o
a.cc:(.text+0xcb): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/cc40wXH4.o
a.cc:(.text+0x111): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/cc40wXH4.o
collect2: error: ld returned 1 exit status
|
s036499010 | p03862 | C++ | #include <bits/stdc++.h>
using namespace std;
/* define const */
/* end up defineing const */
long n;
long a[1000000010];
long x;
int main()
{
cin >> n >> x;
for (int i = 0; i < n; i++) cin >> a[i];
// end up inputting
long cnt = 0;
for (int i = 0; i < n-1; i++) {
if (a[i]+a[i+1] > x) {
long sub = (a[i+1]+a[i])-x;
if (a[i+1] >= sub) {
a[i+1] -= sub;
cnt += sub;
}
else {
a[i] = a[i] - sub + a[i+1];
a[i+1] = 0;
cnt += sub;
}
}
// for (int i = 0; i < n;i++) cout << a[i] << " ";
// cout << endl;
}
cout << cnt << endl;
} | /tmp/ccLVkmXw.o: in function `main':
a.cc:(.text+0x27): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/ccLVkmXw.o
a.cc:(.text+0xcb): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/ccLVkmXw.o
a.cc:(.text+0x111): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/ccLVkmXw.o
collect2: error: ld returned 1 exit status
|
s439345517 | p03862 | C++ | #include <bits/stdc++.h>
using namespace std;
/* define const */
/* end up defineing const */
long N;
long a[1000000010];
long x;
int main()
{
cin >> N >> x;
for (int i = 0; i < N; i++) cin >> a[i];
// end up inputting
long cnt = 0;
for (int i = 0; i < N-1; i++) {
if (a[i]+a[i+1] > x) {
long sub = (a[i+1]+a[i])-x;
if (a[i+1] >= sub) {
a[i+1] -= sub;
cnt += sub;
}
else {
a[i] = a[i] - sub + a[i+1];
a[i+1] = 0;
cnt += sub;
}
}
// for (int i = 0; i < N;i++) cout << a[i] << " ";
// cout << endl;
}
cout << cnt << endl;
} | /tmp/ccLWBbPn.o: in function `main':
a.cc:(.text+0x27): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/ccLWBbPn.o
a.cc:(.text+0xcb): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/ccLWBbPn.o
a.cc:(.text+0x111): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/ccLWBbPn.o
collect2: error: ld returned 1 exit status
|
s751427301 | p03862 | C++ | #include <iostream>
using namespace std;
int main() {
int n, x;
cin >> n >> x;
int a[100010];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
long long d, ans = 0;
for (int i = 0; i < n-1; i++) {
d = a[i] + a[i+1] - x;
if (d > 0) {
ans += d;
a[i+1] = max(a[i+1] - d, 0);
}
}
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:23:25: error: no matching function for call to 'max(long long int, int)'
23 | a[i+1] = max(a[i+1] - d, 0);
| ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:23:25: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
23 | a[i+1] = max(a[i+1] - d, 0);
| ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
|
s337997803 | p03862 | C++ | #include <iostream>
using namespace std;
int main() {
int n, x;
cin >> n >> x;
int a[100010];
for (int i = 0; i < n; i++) {
cin >> a[i];
}
long long ans = 0;
for (int i = 0; i < n-1; i++) {
d = a[i] + a[i+1] - x;
if (d > 0) {
ans += d;
a[i+1] = max(a[i+1] - d, 0);
}
}
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:19:9: error: 'd' was not declared in this scope
19 | d = a[i] + a[i+1] - x;
| ^
|
s792424516 | p03862 | C++ | #include <iostream>
using namespace std;
int f(int x) {
if (n == -1) return 0;
return n / x + 1;
}
int main(int argc, char *argv[]) {
long a, b, x;
cin >> a >> b >> x;
cout << f(b) - f(a - 1) << endl;
return 0;
} | a.cc: In function 'int f(int)':
a.cc:6:13: error: 'n' was not declared in this scope
6 | if (n == -1) return 0;
| ^
a.cc:7:16: error: 'n' was not declared in this scope
7 | return n / x + 1;
| ^
|
s275713409 | p03862 | C++ | #include <iostream>
#include <algorithm>
#include <array>
#include <cmath>
#include <string>
using namespace std;
int main() {
cin>>x;
if(x==3){
cout<<1<<endl;
}
if(x==6){
cout<<11<<endl;
}
if(x==5){
cout<<0<<endl;
}
if(x==2){
cout<<10<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:9:14: error: 'x' was not declared in this scope
9 | cin>>x;
| ^
|
s034704762 | p03862 | C++ | #include <iostream>
#define rep(i,n) for(long long i = 0;i<n;i++)
#define REP(i,k,n) for(long long i=k;i<n;i++)
using namespace std;
int main(){
long long n,x;
long long a[100100];
cin >> n >> x;
rep(i,n){
cin >> a[i];
}
long long ans = 0
if(a[0]>x){
ans += x-a[0];
a[0] = x;
}
for(long long i=0;i<n-1;i++){
long long dist = a[i]+a[i+1]-x;
if(dist > 0){
ans += dist;
a[i+1] -= dist;
}
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:14:3: error: expected ',' or ';' before 'if'
14 | if(a[0]>x){
| ^~
|
s709182554 | p03862 | C++ | #include<bits/stdc++.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
using ll = long long;
using ld =long double;
#define int ll
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<int,pii> piii;
#define mp make_pair
signed main(){
int n,x;cin>>n>>x;
vector<int>v(n);rep(i,n)cin>>v[i];
int ans=0;
int temp=INF;
rep(i,n-1){
if(v[i]+v[i+1]>x){
ans+=v[i]+v[i+1]-x;
v[i+1]=max(0,v[i+1]-(v[i]+v[i+1]-x));
}
}
cout<<ans<<endl;
}
| a.cc: In function 'int main()':
a.cc:32:23: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
32 | v[i+1]=max(0,v[i+1]-(v[i]+v[i+1]-x));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:32:23: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
32 | v[i+1]=max(0,v[i+1]-(v[i]+v[i+1]-x));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:32:23: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
32 | v[i+1]=max(0,v[i+1]-(v[i]+v[i+1]-x));
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
|
s966421560 | p03862 | C++ | import Data.Array.IO
main :: IO ()
main = do
[n, x] <- (map read . words) <$> getLine :: IO [Int]
as <- (map read . words) <$> getLine :: IO [Int]
asArr <- newListArray (0, n - 1) as :: IO (IOArray Int Int)
print =<< solve asArr 1 n x 0
solve :: IOArray Int Int -> Int -> Int -> Int -> Int -> IO Int
solve asArr ptr n x cnt
| ptr == n = return cnt
| otherwise = do
a0 <- readArray asArr (ptr - 1)
a1 <- readArray asArr ptr
if a0 + a1 <= x
then solve asArr (ptr + 1) n x cnt
else do
let toEat = (a0 + a1 - x)
if a1 >= toEat
then do
writeArray asArr ptr (a1 - toEat)
solve asArr (ptr + 1) n x (cnt + toEat)
else do
writeArray asArr ptr 0
writeArray asArr (ptr - 1) (a0 - (toEat - a1))
solve asArr (ptr + 1) n x (cnt + toEat)
| a.cc:1:1: error: 'import' does not name a type
1 | import Data.Array.IO
| ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
|
s772967859 | p03862 | C++ | #include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
//#define ll long long
int n,x;
int a[111111];
ll ans,cnt;
int main(){
cin>>n>>x;
rep(i,n)cin>>a[i];
rep(i,n){
if(a[i]>x){
ans+=a[i]-x;
a[i]=x;
}
}
for(int i=0;i<n-1;i++){
if(a[i]+a[i+1]>x)cnt+=a[i]+a[i+1]-x;
}
cout<<ans+(cnt+1)/2<<endl;
return 0;
}
| a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'?
16 | #define ll __int64
| ^~~~~~~
a.cc:20:1: note: in expansion of macro 'll'
20 | ll ans,cnt;
| ^~
a.cc: In function 'int main()':
a.cc:26:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
26 | ans+=a[i]-x;
| ^~~
| abs
a.cc:32:34: error: 'cnt' was not declared in this scope; did you mean 'int'?
32 | if(a[i]+a[i+1]>x)cnt+=a[i]+a[i+1]-x;
| ^~~
| int
a.cc:35:15: error: 'ans' was not declared in this scope; did you mean 'abs'?
35 | cout<<ans+(cnt+1)/2<<endl;
| ^~~
| abs
a.cc:35:20: error: 'cnt' was not declared in this scope; did you mean 'int'?
35 | cout<<ans+(cnt+1)/2<<endl;
| ^~~
| int
|
s320644511 | p03862 | C++ | #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)
ll sq(ll x){
return x*x;
}
int main(void){
int n,i;
ll a[123456],ans=0ll,x;
cin >> n >> x;
for(i=0; i<n; ++i){
cin >> a[i];
}
for(i=1; i<n; i++){
ans += max(0ll,a[i-1]+a[i]-x);
a[i] = min(a[i],max(0,x-a[i-1]));
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:22:36: error: no matching function for call to 'max(int, ll)'
22 | a[i] = min(a[i],max(0,x-a[i-1]));
| ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:22:36: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
22 | a[i] = min(a[i],max(0,x-a[i-1]));
| ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:22:36: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
22 | a[i] = min(a[i],max(0,x-a[i-1]));
| ~~~^~~~~~~~~~~~
|
s638312778 | p03862 | C | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int descending_compare(const void *a, const void *b){
if (*(int*)a > *(int*)b){
return -1;
}else if (*(int*)a == *(int*)b){
return 0;
}else{
return 1;
}
}
int ascending_compare(const void *a, const void *b){
if (*(int*)a < *(int*)b){
return -1;
}else if (*(int*)a == *(int*)b){
return 0;
}else{
return 1;
}
}
int lower_bound(int *a, int n, int key){
int left, mid, right;
left = 0, right = n;
mid = (left + right)/2;
while ((left+1 != mid || mid+1 != right) && mid != left){
if (key > a[mid]){
left = mid;
}else{
right = mid+1;
}
mid = (left + right)/2;
}
if (a[left] >= key)return left;
if (a[mid] >= key)return mid;
if (a[right] >= key)return right;
return n;
}
//greatest common divisor
unsigned long gcd(unsigned long x, unsigned long y){
if (y == 0){
return x;
}else if (x > y){
return gcd(y, x % y);
}else{
return gcd(x, y % x);
}
}
long long factorial(int x){
long long rtn = 1;
int i;
for (i = x; i > 1; i--){
rtn = (rtn*i);
}
return rtn;
}
/*
int struct_ascending_compare(const void *p, const void *q) {
return ((struct_name*)p)->member_name - ((struct_name*)q)->member_name;
}*/
int long long[100005];
int main(void){
long long n;
long long x;
long long ans = 0;
scanf("%lld %lld", &n, &x);
for (int i = 0; i < n; i++){
scanf("%lld", &a[i]);
}
for (int i = 1; i < n; i++){
if (a[i] + a[i-1] > x){
ans += (a[i] + a[i-1]) - x;
a[i] = a[i] - ((a[i] + a[i-1]) - x) < 0 ? 0:a[i] - ((a[i] + a[i-1]) - x);
}
}
printf("%lld\n", ans);
} | main.c:72:14: error: expected identifier or '(' before '[' token
72 | int long long[100005];
| ^
main.c: In function 'main':
main.c:80:24: error: 'a' undeclared (first use in this function)
80 | scanf("%lld", &a[i]);
| ^
main.c:80:24: note: each undeclared identifier is reported only once for each function it appears in
|
s923308832 | p03862 | C++ | #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std;
long long N;
long long x;
long long a[100010];
int main()
{
cin >> N;
cin >> x;
for(long long i = 1;i <= N;i++)
{
cin >> a[i];
}
long long result = 0;
for(long long i = 1;i <= N;i++)
{
long long sum = a[i - 1] + a[i];
long long r = max(0LL,min(a[i],sum - x));
a[i] -= r;
sum -= r;
result += r;
if(sum > x)
{
long long l = max(0,sum - x);
a[i - 1] -= l;
result += l;
}
}
cout << result << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:38:30: error: no matching function for call to 'max(int, long long int)'
38 | long long l = max(0,sum - x);
| ~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:38:30: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
38 | long long l = max(0,sum - x);
| ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:4:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:38:30: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
38 | long long l = max(0,sum - x);
| ~~~^~~~~~~~~~~
|
s939928945 | p03862 | C++ | #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std;
long long N;
long long x;
long long a[100010];
int main()
{
cin >> N;
cin >> x;
for(long long i = 1;i <= N;i++)
{
cin >> a[i];
}
long long result = 0;
for(long long i = 1;i <= N;i++)
{
long long sum = a[i - 1] + a[i];
long long r = max(0,min(a[i],sum - x));
a[i] -= r;
sum -= r;
result += r;
if(sum > x)
{
long long l = max(0,sum - x);
a[i - 1] -= l;
result += l;
}
}
cout << result << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:29:26: error: no matching function for call to 'max(int, const long long int&)'
29 | long long r = max(0,min(a[i],sum - x));
| ~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:29:26: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
29 | long long r = max(0,min(a[i],sum - x));
| ~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:4:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:29:26: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
29 | long long r = max(0,min(a[i],sum - x));
| ~~~^~~~~~~~~~~~~~~~~~~~~
a.cc:38:30: error: no matching function for call to 'max(int, long long int)'
38 | long long l = max(0,sum - x);
| ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:38:30: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
38 | long long l = max(0,sum - x);
| ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:38:30: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
38 | long long l = max(0,sum - x);
| ~~~^~~~~~~~~~~
|
s558440711 | p03862 | C++ | #include <algorithm>
#include <bitset>
#include <chrono>
#include <complex>
#include <cstdint>
#include <cstring>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <ostream>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;
using ll = int64_t;
using vll = vector<ll>;
struct Solution {
void solve(std::istream& in, std::ostream& out) {
ll n, x;
in >> n >> x;
vll a(n);
for (int i = 0; i < n; i++) {
in >> a[i];
}
vll b(a);
for (int i = 0; i < n - 1; i++) {
if (a[i] + a[i + 1] > x) {
a[i + 1] -= max(0LL, a[i + 1] + a[i] - x);
}
}
ll ans = 0;
for (int i = 0; i < n; i++) {
ans += b[i] - a[i];
}
out << ans << '\n';
}
};
void solve(std::istream& in, std::ostream& out) {
out << std::setprecision(12);
Solution solution;
solution.solve(in, out);
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
istream& in = cin;
ostream& out = cout;
solve(in, out);
return 0;
}
| a.cc: In member function 'void Solution::solve(std::istream&, std::ostream&)':
a.cc:37:32: error: no matching function for call to 'max(long long int, __gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type)'
37 | a[i + 1] -= max(0LL, a[i + 1] + a[i] - x);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:37:32: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type' {aka 'long int'})
37 | a[i + 1] -= max(0LL, a[i + 1] + a[i] - x);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:37:32: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
37 | a[i + 1] -= max(0LL, a[i + 1] + a[i] - x);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
|
s061355871 | p03862 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int n,x,a[MAXN];
int main(){
scanf("%d%d",&n,&x);
for(int i=0;i<n;i++)scanf("%d",&a[i]);
ll ans=0;
for(int i=1;i<n;i++){
ll sum=a[i]+a[i-1];
ll res=max(sum-x,0);
ans+=res;a[i]-=res;
}
printf("%lld\n",ans);
}
| a.cc: In function 'int main()':
a.cc:14:19: error: no matching function for call to 'max(ll, int)'
14 | ll res=max(sum-x,0);
| ~~~^~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:14:19: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
14 | ll res=max(sum-x,0);
| ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:14:19: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
14 | ll res=max(sum-x,0);
| ~~~^~~~~~~~~
|
s700003789 | p03862 | C++ | #include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int n,x;
cin>>n>>x;
vector<int> vec;
for(int i=0;i<n;i++){
int t;
cin>>t;
vec.push_back(t);
}
int ans=0;
for(int i=1;i<vec.size();i++){
int t=max(0,vec[i]+vec[i-1]-x);
vec[i]-=t;
ans+=t;
}
cout<<ans<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:15:18: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
15 | int t=max(0,vec[i]+vec[i-1]-x);
| ~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:15:18: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
15 | int t=max(0,vec[i]+vec[i-1]-x);
| ~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:15:18: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
15 | int t=max(0,vec[i]+vec[i-1]-x);
| ~~~^~~~~~~~~~~~~~~~~~~~~
|
s730424203 | p03862 | C | #include<stdio.h>
int main() {
int i, j, count1 = count2 = 0;
int n, x;
scanf("%d%d", &n, &x);
int arr[n];
int sum;
for(i=0; i<n; i++) {
scanf("%d", &arr[i]);
}
for(i=1; i<n; i+=2) {
sum = arr[i] + arr[i-1];
if(sum>x) count1 += sum-x;
}
for(i=n-2; i>=0; i-=2) {
sum = arr[i] + arr[i+1];
if(sum>x) count2 += sum-x;
}
if(count1 < count2) printf("%d", count1);
else printf("%d", count2);
return 0;
} | main.c: In function 'main':
main.c:3:28: error: 'count2' undeclared (first use in this function); did you mean 'count1'?
3 | int i, j, count1 = count2 = 0;
| ^~~~~~
| count1
main.c:3:28: note: each undeclared identifier is reported only once for each function it appears in
|
s110960973 | p03862 | C++ | #include<bits/stdc++.h>
#define fr(i1,m) for(int i1=0;i1<m;i1++)
using namespace std;
int main()
{
long n,m;
while(cin>>n>>m)
{
long a[100100],s=0,x,y,i;
fr(i,n)
cin>>a[i];
for(i=1;i<n;i++)
{
x=a[i]+a[i-1];
y=x-m;
if(y>0)
{
s+=y;
a[i]=a[i]-y;
a[i]=max(a[i],0);
}
}
cout<<s<<"\n";
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:22:29: error: no matching function for call to 'max(long int&, int)'
22 | a[i]=max(a[i],0);
| ~~~^~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:22:29: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'int')
22 | a[i]=max(a[i],0);
| ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:22:29: note: mismatched types 'std::initializer_list<_Tp>' and 'long int'
22 | a[i]=max(a[i],0);
| ~~~^~~~~~~~
|
s576752542 | p03862 | C++ | #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
ll N,X,A[100005];
ll res=0;
int main()
{
scanf("%lld%lld",&N,&X);
for(int i=0;i<N;i++)scanf("%lld",&A[i]);
if(A[0]>=X)
{
res+=A[i]-(A[i]-X);
A[0]=max(A[0]-X,0LL);
}
for(int i=1;i<N;i++)
{
if(A[i]+A[i-1]>X)
{
res+=(A[i]+A[i-1])-X;
A[i]-=(A[i]+A[i-1])-X;
}
}
printf("%lld\n",res);
return 0;
}
| a.cc: In function 'int main()':
a.cc:26:24: error: 'i' was not declared in this scope
26 | res+=A[i]-(A[i]-X);
| ^
|
s075931046 | p03862 | C | #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define inf 0x3fffffff
int main()
{
int i, n,x,a[110000];
long long sum;
while (~scanf("%d%d", &n, &x))
{
sum = 0;
for (i = 1; i <= n; i++)
scanf("%d", &a[i]);
if (a[1] > x)
{
sum += a[1] - x;
a[1] = x;
}
for (i = 2; i <= n; i++)
{
int flag = a[i] + a[i - 1] - x;
if (flag > 0)
{
sum += flag;
a[i] -= flag;
}
}
printf("%lld\n",sum);
}
return 0;
} | main.c:5:10: fatal error: algorithm: No such file or directory
5 | #include <algorithm>
| ^~~~~~~~~~~
compilation terminated.
|
s421830054 | p03862 | C | /*
C - Boxes and Candies
<http://abc048.contest.atcoder.jp/tasks/arc064_a>
[Tips]
・callocはヒープ領域からメモリの割り当てを行うため遅い<https://oshiete.goo.ne.jp/qa/1726895.html>
*/
#include <stdio.h>
typedef long int int int64_t;
int main(int argc, char const *argv[]) {
int64_t N, x, a, a_next;
int64_t i;
int64_t cnt;
scanf("%d %d", &N, &x);
cnt = 0;
a = 0;
for( i=0; i<N; i++ ){
scanf("%d", &a_next);
if( (a+a_next) > x ){
cnt += (a+a_next) - x;
a_next = x-a;
}
a = a_next;
}
printf("%d\n", cnt);
return 0;
}
| main.c:10:18: error: two or more data types in declaration specifiers
10 | typedef long int int int64_t;
| ^~~
|
s881278394 | p03862 | C | /*
C - Boxes and Candies
<http://abc048.contest.atcoder.jp/tasks/arc064_a>
[Tips]
・callocはヒープ領域からメモリの割り当てを行うため遅い<https://oshiete.goo.ne.jp/qa/1726895.html>
*/
#include <stdio.h>
typedef long int int32_t
int main(int argc, char const *argv[]) {
int32_t N, x, a, a_next;
int32_t i;
int32_t cnt;
scanf("%d %d", &N, &x);
cnt = 0;
a = 0;
for( i=0; i<N; i++ ){
scanf("%d", &a_next);
if( (a+a_next) > x ){
cnt += (a+a_next) - x;
a_next = x-a;
}
a = a_next;
}
printf("%d\n", cnt);
return 0;
}
| main.c:10:25: error: expected ';' before 'int'
10 | typedef long int int32_t
| ^
| ;
11 |
12 | int main(int argc, char const *argv[]) {
| ~~~
main.c: In function 'main':
main.c:14:3: error: unknown type name 'int32_t'
14 | int32_t N, x, a, a_next;
| ^~~~~~~
main.c:9:1: note: 'int32_t' is defined in header '<stdint.h>'; this is probably fixable by adding '#include <stdint.h>'
8 | #include <stdio.h>
+++ |+#include <stdint.h>
9 |
main.c:15:3: error: unknown type name 'int32_t'
15 | int32_t i;
| ^~~~~~~
main.c:15:3: note: 'int32_t' is defined in header '<stdint.h>'; this is probably fixable by adding '#include <stdint.h>'
main.c:16:3: error: unknown type name 'int32_t'
16 | int32_t cnt;
| ^~~~~~~
main.c:16:3: note: 'int32_t' is defined in header '<stdint.h>'; this is probably fixable by adding '#include <stdint.h>'
|
s807672029 | p03862 | C++ | //I_F_A
#include "bits/stdc++.h"
using namespace std;
int main(){
long long n,x;
cin >> n >> x;
long long arr[n+1];
for(long long i=1;i<=n;i++){
cin >> arr[i];
}
for(long long i=2;i<=n;i++){
if(arr[i] + arr[i-1] > x){
long long pr = arr[i-1];
arr[i-1] = max(0LL,(x-arr[i-1]));
ans = ans + abs(pr-arr[i-1]);
}
if(arr[i] + arr[i-1] > x){
long long pr = arr[i];
arr[i] = max(0LL,x-arr[i-1]);
ans = ans + abs(pr-arr[i-1]);
}
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:22:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
22 | ans = ans + abs(pr-arr[i-1]);
| ^~~
| abs
a.cc:28:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
28 | ans = ans + abs(pr-arr[i-1]);
| ^~~
| abs
a.cc:31:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
31 | cout << ans << endl;
| ^~~
| abs
|
s381222920 | p03862 | C++ | //I_F_A
#include "bits/stdc++.h"
using namespace std;
int main(){
long long n,x;
cin >> n >> x;
long long arr[n+1];
for(long long i=1;i<=n;i++){
cin >> arr[i];
}
for(long long i=2;i<=n;i++){
if(arr[i] + arr[i-1] > x){
long long pr = arr[i-1];
arr[i-1] = max(0LL,(x-arr[i-1]))
ans = ans + abs(pr-arr[i-1]);
}
if(arr[i] + arr[i-1] > x){
long long pr = arr[i];
arr[i] = max(0LL,x-arr[i-1]);
ans = ans + abs(pr-arr[i-1]);
}
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:21:57: error: expected ';' before 'ans'
21 | arr[i-1] = max(0LL,(x-arr[i-1]))
| ^
| ;
22 | ans = ans + abs(pr-arr[i-1]);
| ~~~
a.cc:28:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
28 | ans = ans + abs(pr-arr[i-1]);
| ^~~
| abs
a.cc:31:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
31 | cout << ans << endl;
| ^~~
| abs
|
s831070080 | p03862 | C++ |
#include<iostream>
#include<vector>
#include<cinttypes>
#include<limits>
#include<algorithm>
#include<numeric>
//2≤ N ≤10^5
//0≤ a[i] ≤10^9
//0≤ x ≤10^9
using n_type = std::uint32_t;
using a_type = std::int64_t;
using x_type = std::uint32_t;
using veca = std::vector<a_type>;
template<class T>
void print(std::vector<T>& vec) {
for (const auto&v : vec) {
std::cout << v << ", ";
}std::cout << "\n";
}
int main() {
//std::cout << std::numeric_limits<std::uint32_t>::max() << "\n";
n_type N{};
x_type x{};
std::cin >> N >> x;
veca v;
v.reserve(N);
a_type t1{ 0 };
for (size_t i{ 0 }; i < N ; i++) {
std::cin >> t1;
v.push_back(t1);
}
// print(v);
std::uintmax_t count_{};
for (size_t i{ 1 }; i < v.size() ; i++) {
std::int64_t t = v[i-1] + v[i ] - x;
if (t > 0) {
v[i] = std::max( 0LL,v[i]- t);//
count_ += t;
}
//std::cout << t << ", ";
}
//std::cout << "\n";
std::cout << count_ << "\n";
return 0;
} | a.cc: In function 'int main()':
a.cc:44:40: error: no matching function for call to 'max(long long int, __gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type)'
44 | v[i] = std::max( 0LL,v[i]- t);//
| ~~~~~~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:44:40: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type' {aka 'long int'})
44 | v[i] = std::max( 0LL,v[i]- t);//
| ~~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:6:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:44:40: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
44 | v[i] = std::max( 0LL,v[i]- t);//
| ~~~~~~~~^~~~~~~~~~~~~~
|
s115532575 | p03862 | C++ | //AGC 007-A
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cstring>
#include <numeric>
#include <string>
#include <map>
#include <sstream>
using namespace std;
int main(){
int N, x, a[100000]
long ans = 0;
cin >> N >> x;
for (int i = 0; i < N; i++){
cin >> a[i];
if(a[i] > x) {
ans += a[i] - x;
a[i] = x;
}
}
for (int i = 0; i < N - 1; i++){
if(a[i]+a[i+1] > x){
ans += a[i] + a[i+1] - x;
a[i+1] -= a[i] + a[i+1] - x;
}
}
cout << ans << endl;
} | a.cc: In function 'int main()':
a.cc:19:9: error: expected initializer before 'long'
19 | long ans = 0;
| ^~~~
a.cc:22:24: error: 'a' was not declared in this scope
22 | cin >> a[i];
| ^
a.cc:24:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
24 | ans += a[i] - x;
| ^~~
| abs
a.cc:29:20: error: 'a' was not declared in this scope
29 | if(a[i]+a[i+1] > x){
| ^
a.cc:30:25: error: 'ans' was not declared in this scope; did you mean 'abs'?
30 | ans += a[i] + a[i+1] - x;
| ^~~
| abs
a.cc:34:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
34 | cout << ans << endl;
| ^~~
| abs
|
s000945189 | p03862 | C++ | #include "bits/stdc++.h"
using namespace std;
#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
signed main() {
int N, x; cin >> N >> x;
vector<int> a(N); rep(i, 0, N) { cin >> a[i]; }
int ans = 0;
rep(i, 1, N) {
if (a[i - 1] + a[i] > x) {
ans += a[i - 1] + a[i] - x;
a[i] -= a[i - 1] + a[i] - x;
a[i] = max(0, a[i]);
}
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:23:35: error: no matching function for call to 'max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type&)'
23 | a[i] = max(0, a[i]);
| ~~~^~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:23:35: note: deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'})
23 | a[i] = max(0, a[i]);
| ~~~^~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:23:35: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
23 | a[i] = max(0, a[i]);
| ~~~^~~~~~~~~
|
s095209106 | p03862 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdlib>
using namespace std;
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
int *a;
int x;
int ans =0;
cin >> n >> x;
a = new int[n];
vector b(n - 1);
for(int i = 0; i < n; ++i){
cin >> a[i];
}
for(int i = 0; i < n - 1; ++i){
b[i] = a[i] + a[i + 1] - x;
}
while(true){
size_t maxIndex = distance(b.begin(), max_element(b.begin(), b.end()));
if(b[maxIndex] <= 0) break;
--b[maxIndex];
if(maxIndex == 0){
--b[maxIndex + 1];
}else if(maxIndex == b.size() - 1){
--b[maxIndex - 1];
}else{
if(b[maxIndex + 1] > b[maxIndex - 1]){
--b[maxIndex + 1];
}else{
--b[maxIndex - 1];
}
}
++ans;
}
cout << ans;
delete[]a;
return 0;
} | a.cc: In function 'int main()':
a.cc:19:24: error: class template argument deduction failed:
19 | vector b(n - 1);
| ^
a.cc:19:24: error: no matching function for call to 'vector(int)'
In file included from /usr/include/c++/14/vector:66,
from a.cc:2:
/usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate: 'template<class _Tp, class _Alloc, class _InputIterator, class> vector(_InputIterator, _InputIterator, const _Alloc&)-> std::vector<_Tp, _Alloc>'
707 | vector(_InputIterator __first, _InputIterator __last,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::initializer_list<_Tp>, const _Alloc&)-> std::vector<_Tp, _Alloc>'
678 | vector(initializer_list<value_type> __l,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:678:7: note: template argument deduction/substitution failed:
a.cc:19:24: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
19 | vector b(n - 1);
| ^
/usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, std::__type_identity_t<_Alloc>&)-> std::vector<_Tp, _Alloc>'
659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, const _Alloc&, std::false_type)-> std::vector<_Tp, _Alloc>'
640 | vector(vector&& __rv, const allocator_type& __m, false_type)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate expects 3 arguments, 1 provided
/usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&, const _Alloc&, std::true_type)-> std::vector<_Tp, _Alloc>'
635 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate expects 3 arguments, 1 provided
/usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const std::vector<_Tp, _Alloc>&, std::__type_identity_t<_Alloc>&)-> std::vector<_Tp, _Alloc>'
624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>&&)-> std::vector<_Tp, _Alloc>'
620 | vector(vector&&) noexcept = default;
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:620:7: note: template argument deduction/substitution failed:
a.cc:19:24: note: mismatched types 'std::vector<_Tp, _Alloc>' and 'int'
19 | vector b(n - 1);
| ^
/usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const std::vector<_Tp, _Alloc>&)-> std::vector<_Tp, _Alloc>'
601 | vector(const vector& __x)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:601:7: note: template argument deduction/substitution failed:
a.cc:19:24: note: mismatched types 'const std::vector<_Tp, _Alloc>' and 'int'
19 | vector b(n - 1);
| ^
/usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::size_t, const _Tp&, const _Alloc&)-> std::vector<_Tp, _Alloc>'
569 | vector(size_type __n, const value_type& __value,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'template<class _Tp, class _Alloc> vector(std::size_t, const _Alloc&)-> std::vector<_Tp, _Alloc>'
556 | vector(size_type __n, const allocator_type& __a = allocator_type())
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:556:7: note: template argument deduction/substitution failed:
a.cc:19:24: note: couldn't deduce template parameter '_Tp'
19 | vector b(n - 1);
| ^
/usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate: 'template<class _Tp, class _Alloc> vector(const _Alloc&)-> std::vector<_Tp, _Alloc>'
542 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:542:7: note: template argument deduction/substitution failed:
a.cc:19:24: note: couldn't deduce template parameter '_Tp'
19 | vector b(n - 1);
| ^
/usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate: 'template<class _Tp, class _Alloc> vector()-> std::vector<_Tp, _Alloc>'
531 | vector() = default;
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/stl_vector.h:428:11: note: candidate: 'template<class _Tp, class _Alloc> vector(std::vector<_Tp, _Alloc>)-> std::vector<_Tp, _Alloc>'
428 | class vector : protected _Vector_base<_Tp, _Alloc>
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:428:11: note: template argument deduction/substitution failed:
a.cc:19:24: note: mismatched types 'std::vector<_Tp, _Alloc>' and 'int'
19 | vector b(n - 1);
| ^
/usr/include/c++/14/bits/stl_vector.h:2033:5: note: candidate: 'template<class _InputIterator, class _ValT, class _Allocator, class, class> std::vector(_InputIterator, _InputIterator, _Allocator)-> vector<_ValT, _Allocator>'
2033 | vector(_InputIterator, _InputIterator, _Allocator = _Allocator())
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:2033:5: note: candidate expects 2 arguments, 1 provided
|
s326635301 | p03862 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
int n,x;
cin >> n >> x;
vector<int> a(n);
for(int i=0;i<n;i++){
cin >> a[i];
}
long long int ans=0;
vector<int> b(n-1);
for(int i=1;i<a.size();i++){
b[i-1] = a[i-1] + a[i];
}
for(int i=0;i<b.size();i++){
long long int z = max(b[i] - x,0);
b[i]-=z;
b[i+1]=min(b[i+1]-z,0);
ans += z;
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:20:27: error: no matching function for call to 'min(long long int, int)'
20 | b[i+1]=min(b[i+1]-z,0);
| ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:20:27: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
20 | b[i+1]=min(b[i+1]-z,0);
| ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:20:27: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
20 | b[i+1]=min(b[i+1]-z,0);
| ~~~^~~~~~~~~~~~
|
s557285491 | p03862 | C++ | #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)
#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair
int main() {
ll n, a[100010] = {}, x;
cin >> n >> x;
REP(i, n){
cin >> a[i];
}
ll ans = 0;
REP(i, n){
if(a[i] > x){
ans += a[i] - x;
a[i] = x;
}
}
ll ans1 = 0, ans2 = 0;
REP(i, n){
ll maxLR = a[i + 1];
if(i != 0){
maxLR = max(maxLR, a[i - 1]);
}
if(i % 2 == 0){
if(a[i] + maxLR > x){
ans1 += max(a[i] + maxLR - x, 0);
}
}else{
if(a[i] + maxLR > x){
ans2 += max(a[i] + maxLR - x, 0);
}
}
}
ans += min(ans1, ans2);
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:46:44: error: no matching function for call to 'max(long long int, int)'
46 | ans1 += max(a[i] + maxLR - x, 0);
| ~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:46:44: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
46 | ans1 += max(a[i] + maxLR - x, 0);
| ~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:46:44: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
46 | ans1 += max(a[i] + maxLR - x, 0);
| ~~~^~~~~~~~~~~~~~~~~~~~~
a.cc:50:44: error: no matching function for call to 'max(long long int, int)'
50 | ans2 += max(a[i] + maxLR - x, 0);
| ~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:50:44: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
50 | ans2 += max(a[i] + maxLR - x, 0);
| ~~~^~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:50:44: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
50 | ans2 += max(a[i] + maxLR - x, 0);
| ~~~^~~~~~~~~~~~~~~~~~~~~
|
s103954100 | p03862 | C++ | #include <iostream>
#include <map>
#include <string>
using namespace std;
int main() {
long long a[100000];
int n, x:
long long cnt = 0;
cin >> n >> x;
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
for (int i = 1; i < n; ++i) {
if (a[i] + a[i - 1] > x) {
int tmp = a[i] + a[i - 1] - x;
a[i] -= tmp;
cnt += tmp;
}
}
cout << cnt << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:7:17: error: expected initializer before ':' token
7 | int n, x:
| ^
a.cc:9:21: error: 'x' was not declared in this scope
9 | cin >> n >> x;
| ^
a.cc:17:25: error: 'cnt' was not declared in this scope; did you mean 'int'?
17 | cnt += tmp;
| ^~~
| int
a.cc:20:17: error: 'cnt' was not declared in this scope; did you mean 'int'?
20 | cout << cnt << endl;
| ^~~
| int
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.