submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3
values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s850923974 | p03732 | C++ | #include <bits/stdc++.h>
using namespace std;
#define MAX_N 100
#define MAX_W 1000
long long n;
long long dp[MAX_N+1][MAX_W+1];
long long weight[MAX_N+1];
long long cost[MAX_N+1];
long long CAP;
long long func(long long i,long long w)
{
if(i==n+1) return 0;
if(dp[i][w]!=-1) return dp[i][w];
long long profit1=0,profit2=0;
if(w+weight[i]<=CAP)
profit1=cost[i]+func(i+1,w+weight[i]);
profit2=func(i+1,w);
dp[i][w]=max(profit1,profit2);
return dp[i][w];
}
void main()
{
//freopen("in","r",stdin);
memset(dp,-1,sizeof(dp));
scanf("%lld%lld",&n,&CAP);
for(long long i=1; i<=n; i++)
{
scanf("%lld %lld",&weight[i],&cost[i]);
}
printf("%lld\n",func(1,0));
} | a.cc:24:1: error: '::main' must return 'int'
24 | void main()
| ^~~~
|
s176174595 | p03732 | C++ | #include<iostream>
//#define int long long int
using namespace std;
int dp[105][105];
int n,tw,v[105],w[105],i,j;
knap(int n,int tw)
{
int i,j;
for(i=0; i<n; i++)
{
for(j=0; j<=tw; j++)
{
if(j==0) dp[i][j]=0;
else if(j<w[i])dp[i][j]=dp[i-1][j];
else dp[i][j]=max(v[i]+dp[i-1][j-w[i]],dp[i-1][j]);
}
}
return dp[n-1][tw];
}
int main()
{
while(cin>>n>>tw)
{
for(i=0;i<n;i++)
{
cin>>w[i]>>v[i];
}
cout<<knap(n,tw)<<endl;
}
return 0;
}
| a.cc:6:1: error: ISO C++ forbids declaration of 'knap' with no type [-fpermissive]
6 | knap(int n,int tw)
| ^~~~
|
s428168641 | p03732 | C++ | #include <iostream>
#include <algorithm>
#include <cstdio>
#define Max(a,b) a>b?a:b
#define INF 10000000000000000
using namespace std;
typedef long long LL;
const int MAX = 110;
LL weight[MAX], value[MAX];
LL W;
pair<LL, LL> ps[1 << (MAX / 2)];
int n;
void slove()
{
//枚举前半部分
int n2 = n / 2;
for (int i = 0; i < 1 << n2; i++)//前半部分的枚举总数为 2^(n/2);
{
LL sw = 0, sv = 0;
//每种结果选取特定的价值和重量(i.e 一共2个东西,就一共四种情况,都不选,选第一个,选第二个,都选)
for (int j = 0; j < n2; j++)
{
if (i >> j & 1)
{
sw += weight[j];
sv += value[j];
}
}
ps[i] = make_pair(sw, sv);//加入到ps数组中
}
//对ps排序
sort(ps, ps + (1 << n2));
//ps 去重
int m = 1;
for (int i = 1; i < 1 << n2; i++)
if (ps[m - 1].second < ps[i].second)
ps[m++] = ps[i];
LL res = 0;//保存结果
//枚举后半部分, 并且找到最优解
for (int i = 0; i < 1 << (n - n2); i++)//同样枚举的总个数
{
LL sw = 0, sv = 0;
for (int j = 0; j < n - n2; j++)//和前半部分的一样
{
if (i >> j & 1)
{
sw += weight[n2 + j];
sv += value[n2 + j];
}
}
if (sw <= W)//加个判断求解最大价值,只有小于背包容量的时候
{
LL tv = (lower_bound(ps, ps + m, make_pair(W - sw, INF)) - 1)->second;//找到前半部分对应的value
res = Max(res, sv + tv);
}
}
printf("%lld\n", res);
}
int main()
{
while (~scanf("%d %lld", &n, &W))
{
for (int i = 0; i < n; i++)
scanf("%lld %lld", &weight[i], &value[i]);
slove();
}
return 0;
} | a.cc:11:19: warning: left shift count >= width of type [-Wshift-count-overflow]
11 | pair<LL, LL> ps[1 << (MAX / 2)];
| ~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:71,
from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = std::pair<long long int, long long int>*; _Value = const std::pair<long long int, long int>]':
/usr/include/c++/14/bits/stl_algobase.h:1504:14: required from '_ForwardIterator std::__lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&, _Compare) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>; _Compare = __gnu_cxx::__ops::_Iter_less_val]'
1504 | if (__comp(__middle, __val))
| ~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:1539:32: required from '_ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&) [with _ForwardIterator = pair<long long int, long long int>*; _Tp = pair<long long int, long int>]'
1539 | return std::__lower_bound(__first, __last, __val,
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
1540 | __gnu_cxx::__ops::__iter_less_val());
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:53:33: required from here
53 | LL tv = (lower_bound(ps, ps + m, make_pair(W - sw, INF)) - 1)->second;//找到前半部分对应的value
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/predefined_ops.h:69:22: error: no match for 'operator<' (operand types are 'std::pair<long long int, long long int>' and 'const std::pair<long long int, long int>')
69 | { return *__it < __val; }
| ~~~~~~^~~~~~~
In file included from /usr/include/c++/14/string:48:
/usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)'
1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>'
69 | { return *__it < __val; }
| ~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)'
1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>'
69 | { return *__it < __val; }
| ~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
448 | operator<(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>'
69 | { return *__it < __val; }
| ~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
493 | operator<(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>'
69 | { return *__it < __val; }
| ~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1694 | operator<(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::move_iterator<_IteratorL>'
69 | { return *__it < __val; }
| ~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1760 | operator<(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::move_iterator<_IteratorL>'
69 | { return *__it < __val; }
| ~~~~~~^~~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:64:
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note: deduced conflicting types for parameter '_T2' ('long long int' and 'long int')
69 | { return *__it < __val; }
| ~~~~~~^~~~~~~
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54:
/usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
673 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
69 | { return *__it < __val; }
| ~~~~~~^~~~~~~
/usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)'
680 | operator< (basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
69 | { return *__it < __val; }
| ~~~~~~^~~~~~~
/usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)'
688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
69 | { return *__it < __val; }
| ~~~~~~^~~~~~~
/usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
69 | { return *__it < __val; }
| ~~~~~~^~~~~~~
/usr/include/c++/14/bits/basic_string.h:3888:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)'
3888 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3888:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/bits/predefined_ops.h:69:22: note: 'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>'
69 | { |
s309361825 | p03732 | C++ | #include<bits/stdc++.h>
//#define int long long int
using namespace std;
int dp[105][105];
int n,tw,v[105],w[105],i,j;
knap(int n,int tw)
{
int i,j;
for(i=0; i<n; i++)
{
for(j=0; j<=tw; j++)
{
if(j==0) dp[i][j]=0;
else if(j<w[i])dp[i][j]=dp[i-1][j];
else dp[i][j]=max(v[i]+dp[i-1][j-w[i]],dp[i-1][j]);
}
}
return dp[n-1][tw];
}
int main()
{
while(cin>>n>>tw)
{
for(i=0;i<n;i++)
{
cin>>w[i]>>v[i];
}
cout<<knap(n,tw)<<endl;
}
return 0;
}
| a.cc:6:1: error: ISO C++ forbids declaration of 'knap' with no type [-fpermissive]
6 | knap(int n,int tw)
| ^~~~
|
s407631096 | p03732 | C++ | #include<bits/stdc++.h>
using namespace std;
int dp[105][105];
int n,tw,v[105],w[105],i,j;
knap(int n,int tw)
{
int i,j;
for(i=0; i<n; i++)
{
for(j=0; j<=tw; j++)
{
if(j==0) dp[i][j]=0;
else if(j<w[i])dp[i][j]=dp[i-1][j];
else dp[i][j]=max(v[i]+dp[i-1][j-w[i]],dp[i-1][j]);
}
}
return dp[n-1][tw];
}
int main()
{
while(cin>>n>>tw)
{
for(i=0;i<n;i++)
{
cin>>w[i]>>v[i];
}
cout<<knap(n,tw)<<endl;
}
}
| a.cc:5:1: error: ISO C++ forbids declaration of 'knap' with no type [-fpermissive]
5 | knap(int n,int tw)
| ^~~~
|
s231866709 | p03732 | C++ | #include<bits/stdc++.h>
using namespace std;
int dp[105][105];
int n,tw,v[105],w[105],i,j;
knap(int n,int tw)
{
int i,j;
for(i=0; i<n; i++)
{
for(j=0; j<=tw; j++)
{
if(j==0) dp[i][j]=0;
else if(j<w[i])dp[i][j]=dp[i-1][j];
else dp[i][j]=max(v[i]+dp[i-1][j-w[i]],dp[i-1][j]);
}
}
return dp[n-1][tw];
}
int main()
{
while(cin>>n>>tw)
{
for(i=0;i<n;i++)
{
cin>>w[i]>>v[i];
}
cout<<knap(n,tw)<<endl;
}
}
| a.cc:5:1: error: ISO C++ forbids declaration of 'knap' with no type [-fpermissive]
5 | knap(int n,int tw)
| ^~~~
|
s213014973 | p03732 | C++ | #include <iostream>
#include <algorithm>
using namespace std;
const int MAX_N = 100; // nの最大値
const int MAX_W = 810; // Wの最大値
int N, W;
int w[810], v[810];
int standard[1];
// メモ化テーブル。
// dp[i][j]はi番目以降の品物から重さの和がj以下なるように選んだときの価値の和の最大値を表す。
// -1なら値が未決定であることを表す
int dp[MAX_N + 1][MAX_W + 1];
// i番目以降の品物から重さの和がj以下なるように選んだときの、
// 取りうる価値の総和の最大値を返す関数
int rec_dp(int i, int j) {
if (dp[i][j] != -1) {
// すでに調べたことがあるならその結果を再利用
return dp[i][j];
}
int res;
if (i == N) {
// 品物がもう残っていないときは、価値の和の最大値は0で確定
res = 0;
}
else if (j < w[i]) {
// 残りの容量が足りず品物iを入れられないので、入れないパターンだけ処理
res = rec_dp(i + 1, j);
}
else {
// 品物iを入れるか入れないか選べるので、両方試して価値の和が大きい方を選ぶ
res = max(
rec_dp(i + 1, j),
rec_dp(i + 1, j - w[i]) + v[i]
);
}
// 結果をテーブルに記憶する
return dp[i][j] = res;
}
int solve_dp(int W) {
memset(dp, -1, sizeof(dp)); // メモ化テーブルを-1で初期化 以下のforループと等価
// for (int i = 0; i < MAX_N + 1; i++)
// for (int j = 0; j < MAX_W + 1; j++)
// dp[i][j] = -1;
// 0番目以降で容量W以下の場合の結果を表示する
return rec_dp(0, W);
}
int main() {
cin >> N >> W;
for (int i = 0; i < N; i++)cin >> w[i] >> v[i];
standard[1] = w[0];
for (int i = 0; i < N; i++)w[i] -= standard[1];
int ans = 0;
for (int i = 0; i < N; i++) {
ans = max(ans, rec_dp(0, W - standard[1] * i));
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int solve_dp(int)':
a.cc:45:9: error: 'memset' was not declared in this scope
45 | memset(dp, -1, sizeof(dp)); // メモ化テーブルを-1で初期化 以下のforループと等価
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include <algorithm>
+++ |+#include <cstring>
3 | using namespace std;
|
s033019574 | p03732 | C++ | #include <cstdio>
#include <vector>
#include <algorithm>
#define NMAX 105
#define WMAX 1000000005
#define DIAGONAL 1
#define TOP 0
using namespace std;
struct Item {
int value, weight;
};
int N, W;
Item items[NMAX + 1];
int C[NMAX + 1][WMAX + 1], G[NMAX + 1][WMAX + 1];
void compute(int &maxValue, vector<int> &selection) {
for (int w = 0; w <= W; w++) {
C[0][w] = 0;
C[0][w] = DIAGONAL;
}
for (int i = 1; i <= N; i++) C[i][0] = 0;
for (int i = 1; i <= N; i++) {
for (int w = 1; w <= W; w++) {
C[i][w] = C[i - 1][w];
G[i][w] = TOP;
if (items[i].weight > w) continue;
if (items[i].value + C[i - 1][w - items[i].weight] > C[i - 1][w]) {
C[i][w] = items[i].value + C[i - 1][w - items[i].weight];
G[i][w] = DIAGONAL;
}
}
}
maxValue = C[N][W];
selection.clear();
for (int i = N, w = W; i >= 1; i--) {
if (G[i][w] == DIAGONAL) {
selection.push_back(i);
w -= items[i].weight;
}
}
reverse(selection.begin(), selection.end());
}
void input() {
scanf("%d%d", &N, &W);
for (int i = 1; i <= N; i++) {
scanf("%d%d", &items[i].value, &items[i].weight);
}
}
int main() {
int maxValue;
vector<int> selection;
input();
compute(maxValue, selection);
printf("%d", maxValue);
return 0;
}
| /tmp/cc8CH3D0.o: in function `compute(int&, std::vector<int, std::allocator<int> >&)':
a.cc:(.text+0x11d): relocation truncated to fit: R_X86_64_PC32 against symbol `G' defined in .bss section in /tmp/cc8CH3D0.o
a.cc:(.text+0x27d): relocation truncated to fit: R_X86_64_PC32 against symbol `G' defined in .bss section in /tmp/cc8CH3D0.o
a.cc:(.text+0x324): relocation truncated to fit: R_X86_64_PC32 against symbol `G' defined in .bss section in /tmp/cc8CH3D0.o
collect2: error: ld returned 1 exit status
|
s772349561 | p03732 | C++ | #include <iostream>
using namespace std;
long* w;
long* v;
long dp[1000000000 + 1][100 + 1];
long solve(long weight, int select) {
if (dp[weight][select] >= 0) {
return dp[weight][select];
}
if (weight < 0 || select < 0) {
return 0;
} else if (weight - w[select] >= 0){
return max(solve(weight - w[select], select - 1) + v[select], solve(weight, select - 1));
} else {
return solve(weight, select - 1);
}
}
int main() {
int N;
long W;
cin >> N;
cin >> W;
w = (long*)malloc(sizeof(long) * N);
v = (long*)malloc(sizeof(long) * N);
for (int i = 0; i < N; i++) {
cin >> w[i];
cin >> v[i];
}
memset(dp, -1, sizeof(dp));
cout << solve(W, N - 1) << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:33:3: error: 'memset' was not declared in this scope
33 | memset(dp, -1, sizeof(dp));
| ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
1 | #include <iostream>
+++ |+#include <cstring>
2 | using namespace std;
|
s574787868 | p03732 | C++ | #include <bits/stdc++.h>
//#define DEBUG
#define INF ll_MAX
#define BEAMMAX 10
typedef long long ll;
using namespace std;
int main() {
ll N, W;
cin >> N >> W;
vector<ll> v(N), w(N);
for(int i=0; i<N; ++i) {
cin >> v[i] >> w[i];
}
if(N <= 30) {
int s = N/2;
vector< pair<ll,ll> > dp(1 << s);
for(int i=0; i<(1 << s); ++i) {
ll sw = 0, sv = 0;
for(int j=0; j<s; ++j) {
if(i >> j & 1) {
sw += w[j];
sv += v[j];
}
}
dp[i] = make_pair(sw, sv);
}
sort(dp.begin(), dp.end());
int m = 1;
for(int i=1; i<1<<s; ++i) {
if(dp[m-1].second < dp[i].second) {
dp[m++] = dp[i];
}
}
ll res = 0;
for(int i=0; i<1<<(N - s); ++i) {
ll sw = 0, sv = 0;
for(int j=0; j<N-s; ++j) {
if(i >> j & 1) {
sw += w[j+s];
sv += v[j+s];
}
}
if(sw <= W) {
ll tv = (lower_bound(dp.begin(), dp.begin()+m, make_pair(W-sw, INF)) - 1)->second;
res = max(res, sv+tv);
}
}
cout << res << endl;
} else if(*max_element(v.begin(), v.end()) <= 1000) {
ll V = accumulate(v.begin(), v.end(), 0LL);
vector<ll> dp(V+1, INF);
dp[0] = 0;
for(int i=0; i<N; ++i) {
for(int j=V-v[i]; j>=0; --j) {
dp[j+v[i]] = min(dp[j+v[i]], dp[j] + w[i]);
}
}
for(int i=V; i>=0; --i) {
if(dp[i] <= W) {
cout << i << endl;
return 0;
}
}
} else {
vector<ll> dp(W+1, -1);
dp[0] = 0;
for(int i=0; i<N; ++i) {
for(int j=W-w[i]; j>=0; --j) {
if(dp[j] == -1) {
continue;
}
dp[j+w[i]] = max(dp[j+w[i]], dp[j] + v[i]);
}
}
cout << *max_element(dp.begin(), dp.end()) << endl;
}
} | a.cc: In function 'int main()':
a.cc:5:13: error: 'll_MAX' was not declared in this scope
5 | #define INF ll_MAX
| ^~~~~~
a.cc:49:80: note: in expansion of macro 'INF'
49 | ll tv = (lower_bound(dp.begin(), dp.begin()+m, make_pair(W-sw, INF)) - 1)->second;
| ^~~
a.cc:5:13: error: 'll_MAX' was not declared in this scope
5 | #define INF ll_MAX
| ^~~~~~
a.cc:56:28: note: in expansion of macro 'INF'
56 | vector<ll> dp(V+1, INF);
| ^~~
|
s412786516 | p03732 | C++ | #include <bits/stdc++.h>
//#define DEBUG
#define INF ll_MAX
#define BEAMMAX 10
typedef long long ll;
using namespace std;
int main() {
ll N, W;
cin >> N >> W;
vector<ll> v(N), w(N);
for(int i=0; i<N; ++i) {
cin >> v[i] >> w[i];
}
if(N <= 30) {
int s = N/2;
vector<P> dp(1 << s);
for(int i=0; i<(1 << s); ++i) {
ll sw = 0, sv = 0;
for(int j=0; j<s; ++j) {
if(i >> j & 1) {
sw += w[j];
sv += v[j];
}
}
dp[i] = make_pair(sw, sv);
}
sort(dp.begin(), dp.end());
int m = 1;
for(int i=1; i<1<<s; ++i) {
if(dp[m-1].second < dp[i].second) {
dp[m++] = dp[i];
}
}
ll res = 0;
for(int i=0; i<1<<(N - s); ++i) {
ll sw = 0, sv = 0;
for(int j=0; j<N-s; ++j) {
if(i >> j & 1) {
sw += w[j+s];
sv += v[j+s];
}
}
if(sw <= W) {
ll tv = (lower_bound(dp.begin(), dp.begin()+m, make_pair(W-sw, INF)) - 1)->second;
res = max(res, sv+tv);
}
}
cout << res << endl;
} else if(*max_element(v.begin(), v.end()) <= 1000) {
ll V = accumulate(v.begin(), v.end(), 0LL);
vector<ll> dp(V+1, INF);
dp[0] = 0;
for(int i=0; i<N; ++i) {
for(int j=V-v[i]; j>=0; --j) {
dp[j+v[i]] = min(dp[j+v[i]], dp[j] + w[i]);
}
}
for(int i=V; i>=0; --i) {
if(dp[i] <= W) {
cout << i << endl;
return 0;
}
}
} else {
vector<ll> dp(W+1, -1);
dp[0] = 0;
for(int i=0; i<N; ++i) {
for(int j=W-w[i]; j>=0; --j) {
if(dp[j] == -1) {
continue;
}
dp[j+w[i]] = max(dp[j+w[i]], dp[j] + v[i]);
}
}
cout << *max_element(dp.begin(), dp.end()) << endl;
}
} | a.cc: In function 'int main()':
a.cc:21:16: error: 'P' was not declared in this scope
21 | vector<P> dp(1 << s);
| ^
a.cc:21:17: error: template argument 1 is invalid
21 | vector<P> dp(1 << s);
| ^
a.cc:21:17: error: template argument 2 is invalid
a.cc:30:15: error: invalid types 'int[int]' for array subscript
30 | dp[i] = make_pair(sw, sv);
| ^
a.cc:32:17: error: request for member 'begin' in 'dp', which is of non-class type 'int'
32 | sort(dp.begin(), dp.end());
| ^~~~~
a.cc:32:29: error: request for member 'end' in 'dp', which is of non-class type 'int'
32 | sort(dp.begin(), dp.end());
| ^~~
a.cc:35:18: error: invalid types 'int[int]' for array subscript
35 | if(dp[m-1].second < dp[i].second) {
| ^
a.cc:35:35: error: invalid types 'int[int]' for array subscript
35 | if(dp[m-1].second < dp[i].second) {
| ^
a.cc:36:19: error: invalid types 'int[int]' for array subscript
36 | dp[m++] = dp[i];
| ^
a.cc:36:29: error: invalid types 'int[int]' for array subscript
36 | dp[m++] = dp[i];
| ^
a.cc:49:41: error: request for member 'begin' in 'dp', which is of non-class type 'int'
49 | ll tv = (lower_bound(dp.begin(), dp.begin()+m, make_pair(W-sw, INF)) - 1)->second;
| ^~~~~
a.cc:49:53: error: request for member 'begin' in 'dp', which is of non-class type 'int'
49 | ll tv = (lower_bound(dp.begin(), dp.begin()+m, make_pair(W-sw, INF)) - 1)->second;
| ^~~~~
a.cc:5:13: error: 'll_MAX' was not declared in this scope
5 | #define INF ll_MAX
| ^~~~~~
a.cc:49:80: note: in expansion of macro 'INF'
49 | ll tv = (lower_bound(dp.begin(), dp.begin()+m, make_pair(W-sw, INF)) - 1)->second;
| ^~~
a.cc:5:13: error: 'll_MAX' was not declared in this scope
5 | #define INF ll_MAX
| ^~~~~~
a.cc:56:28: note: in expansion of macro 'INF'
56 | vector<ll> dp(V+1, INF);
| ^~~
|
s991302404 | p03732 | C++ | #include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
#include<cctype>
#define itn int
#define pritnf printf
#define xlm mylove
#define maxt 1000000010
#define maxm 110
using namespace std;
int w[maxm],c[maxm];int t,m;int f[maxt][maxm];
inline void readln(){
scanf("%d%d",&m,&t);
for (int i=1;i<=m;i++){
scanf("%d%d",&w[i],&c[i]);
//if (w[i]>t){w[i]=c[i]=0;}
}
}
inline void dp(){
for (int i=1;i<=m;i++){
for (int v=t;v>=0;v--){
if (w[i]<=v) f[i][v]=max(f[i-1][v],f[i-1][v-w[i]]+c[i]);
else f[i][v]=f[i-1][v];
}
}
}
inline void p(){
printf("%d",f[m][t]);
fclose(stdin);fclose(stdout);
}
int Main(){
readln();
dp();
p();
return 0;
}
int main(){;}
int xlm=Main(); | /tmp/ccDT2N82.o: in function `__static_initialization_and_destruction_0()':
a.cc:(.text+0x30): relocation truncated to fit: R_X86_64_PC32 against symbol `mylove' defined in .bss section in /tmp/ccDT2N82.o
collect2: error: ld returned 1 exit status
|
s780325487 | p03732 | Java | public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
final int N = sc.nextInt();
final int W = sc.nextInt();
int[] w = new int[N];
int[] v = new int[N];
for(int i=0; i<N; i++){
w[i] = sc.nextInt();
v[i] = sc.nextInt();
}
sc.close();
int[][] dp = new int[N+1][W+1];
int ret = 0;
for (int i = 0; i < N; i++) {
for (int j = 0; j <= W; j++) {
dp[i + 1][j] = Math.max(dp[i + 1][j], dp[i][j]);
if (j + w[i] <= W) {
dp[i + 1][j + w[i]] = Math.max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
ret = Math.max(ret, dp[i + 1][j + w[i]]);
}
}
}
System.out.println(ret);
}
} | Main.java:5: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:5: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
2 errors
|
s173672673 | p03732 | C++ | #include<iostream>
using namespace std;
#define V 1000000000
unsigned int f[100][V];
unsigned int weight[100];
unsigned int value[100];
#define max(x,y) (x)>(y)?(x):(y)
int main()
{
int N,M;
cin>>N;
cin>>M;
for (int i=1;i<=N; i++)
{
cin>>weight[i]>>value[i];
}
for (int i=1; i<=N; i++)
for (int j=1; j<=M; j++)
{
if (weight[i]<=j)
{
f[i][j]=max(f[i-1][j],f[i-1][j-weight[i]]+value[i]);
}
else
f[i][j]=f[i-1][j];
}
cout<<f[N][M]<<endl;
} | /tmp/ccC7vP70.o: in function `main':
a.cc:(.text+0x4d): relocation truncated to fit: R_X86_64_PC32 against symbol `weight' defined in .bss section in /tmp/ccC7vP70.o
a.cc:(.text+0x79): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccC7vP70.o
a.cc:(.text+0xbf): relocation truncated to fit: R_X86_64_PC32 against symbol `weight' defined in .bss section in /tmp/ccC7vP70.o
a.cc:(.text+0xea): relocation truncated to fit: R_X86_64_PC32 against symbol `weight' defined in .bss section in /tmp/ccC7vP70.o
a.cc:(.text+0x124): relocation truncated to fit: R_X86_64_PC32 against symbol `value' defined in .bss section in /tmp/ccC7vP70.o
collect2: error: ld returned 1 exit status
|
s647453945 | p03732 | C++ | #include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define scii(x, y) int x,y;scanf("%d%d",&x,&y);
#define REP(i, y) for(int i=0;i<y;i++)
const int MAX_N = 110;
const int MAX_W = 1000000010;
int dp[MAX_N][MAX_W];
int w[MAX_N];
int v[MAX_N];
int main() {
scii(N, W)
REP(i,N) {
scanf("%d%d",&w[i], &v[i]);
}
REP(i, N+1) {
REP(c, W+1) {
if (i==0||c==0)
dp[i][c] = 0;
else if (c >= w[i-1]) {
dp[i][c] = max(v[i-1] + dp[i-1][c-w[i-1]], dp[i-1][c]);
} else {
dp[i][c] = dp[i-1][c];
}
}
}
printf("%d\n", dp[N][W]);
} | /tmp/ccBXviCp.o: in function `main':
a.cc:(.text+0x40): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccBXviCp.o
a.cc:(.text+0x57): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccBXviCp.o
a.cc:(.text+0xe8): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccBXviCp.o
a.cc:(.text+0x136): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/ccBXviCp.o
a.cc:(.text+0x156): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/ccBXviCp.o
collect2: error: ld returned 1 exit status
|
s281136898 | p03732 | C++ | #include<bits/stdc++.h>
#include <corecrt_memcpy_s.h>
const long long INF = INT_MAX / 2;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
using namespace std;
//ll n, k, ans = 0, sum = 0, cnt = 0;
//string s;
//vector<ll> v;
//vector<ll> v1;
//vector < pair<ll, ll > > vp;
//vector<vector<ll> > vv(50, vector<ll>(50, INF));
//vector<string> vs;
//vector<char> vc;
//set<ll> st;
//map<char, ll> mp;
/*--------------------template--------------------*/
#include<iostream>
#include<vector>
#define MAX 100
#define DIAGONAL 1
#define LEFT 0
struct Item {
int value, weight;
};
int n;
Item items[MAX];
int C[MAX + 1][MAX + 1], G[MAX + 1][MAX + 1];
int weight;
void compute(int &maxValue, vector<int> &path) {
for (int w = 0; w <= weight; w++) {
C[0][w] = 0;
G[0][w] = DIAGONAL;
}
for (int i = 1; i <= n; i++) C[i][0] = 0;
for (int i = 1; i <= n; i++) {
for (int w = 1; w <= weight; w++) {
if (items[i].weight <= w) {
if (items[i].value + C[i - 1][w - items[i].weight] > C[i - 1][w]) {
C[i][w] = items[i].value + C[i - 1][w - items[i].weight];
G[i][w] = DIAGONAL;
} else {
C[i][w] = C[i - 1][w];
G[i][w] = LEFT;
}
} else {
C[i][w] = C[i - 1][w];
G[i][w] = LEFT;
}
}
}
maxValue = C[n][weight];
path.clear();
int w = weight;
for (int i = n; i >= 1; i--) {
if (G[i][w] == DIAGONAL) {
path.push_back(i);
w -= items[i].weight;
}
}
reverse(path.begin(), path.end());
}
void input() {
cin >> n >> weight;
for (int i = 1; i <= n; i++) {
cin >> items[i].weight >> items[i].value;
}
}
int main() {
int maxValue;
vector<int> path;
input();
compute(maxValue, path);
cout << maxValue << endl;
} | a.cc:2:10: fatal error: corecrt_memcpy_s.h: No such file or directory
2 | #include <corecrt_memcpy_s.h>
| ^~~~~~~~~~~~~~~~~~~~
compilation terminated.
|
s388505148 | p03732 | C++ | #include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define DEBUG(X) cerr<<__LINE__<<" "<<#X<<": "<<X<<endl;
#define sci(x) int x;scanf("%d",&x);
#define scii(x, y) int x,y;scanf("%d%d",&x,&y);
#define REP(i, y) for(int i=0;i<y;i++)
const int MAX_N = 110;
const int MAX_W = 1e9+10;
int dp[MAX_N][MAX_W];
int w[MAX_N];
int v[MAX_N];
int main() {
scii(N, W)
REP(i,N) {
scanf("%d%d",&w[i], &v[i]);
}
REP(i, N+1) {
REP(c, W+1) {
if (i==0||c==0)
dp[i][c] = 0;
else if (c >= w[i-1]) {
dp[i][c] = max(v[i-1] + dp[i-1][c-w[i-1]], dp[i-1][c]);
} else {
dp[i][c] = dp[i-1][c];
}
}
}
printf("%d\n", dp[N][W]);
} | /tmp/cclEJStv.o: in function `main':
a.cc:(.text+0x40): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cclEJStv.o
a.cc:(.text+0x57): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/cclEJStv.o
a.cc:(.text+0xe8): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/cclEJStv.o
a.cc:(.text+0x136): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cclEJStv.o
a.cc:(.text+0x156): relocation truncated to fit: R_X86_64_PC32 against symbol `w' defined in .bss section in /tmp/cclEJStv.o
collect2: error: ld returned 1 exit status
|
s840797441 | p03733 | Java | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int T = sc.nextInt();
int t[] = new int[N];
int total = 0;
for(int i = 0; i <t.length; ++i){
t[i] = sc.nextInt();
}
for(int i = 0; i <t.length; ++i){
int num1 = t[i+1] - t[i];
}
total = Math.min(T, num1);
System.out.println(total);
}
} | Main.java:16: error: cannot find symbol
total = Math.min(T, num1);
^
symbol: variable num1
location: class Main
1 error
|
s634904314 | p03733 | Java | public class Main {
public static void main(String[] args) throws Exception {
//値の取得
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
long T = sc.nextLong();
long[] t = new long[N];
for (int i = 0; i < N; ++i){
t[i] = sc.nextLong();
}
long X = 0; //総和
for (int i = 0; i < N-1; ++i){
X += Math.min(T,t[i+1]-t[i]); //t[i+1]-t[i]:次の人が来るまでの時間
}
X += T; //最後にTを加える
System.out.println(X);
}
} | Main.java:4: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:4: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
2 errors
|
s046172204 | p03733 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n,t;
cin>>n>>t;
vector<long long>a(n);
for(int i=0;i<n;i++) cin>>a[i];
long long ans=t;
for(int i=0;i<n-1;i++){
if(a[i+1]-a[i]>k) ans+=k;
else ans+=a[i+1]-a[i];
}
cout<<ans<<endl;
}
| a.cc: In function 'int main()':
a.cc:11:20: error: 'k' was not declared in this scope
11 | if(a[i+1]-a[i]>k) ans+=k;
| ^
|
s593675393 | p03733 | C++ | #include <bits/stdc++.h>
using namespace std;
int main()
{
int n,t;
cin >> n >> t;
vector<int> ti(i);
for (int i = 0; i < n; i++)
{
cin >> ti[i];
}
int ans = t;
for (int i = 1; i < n - 1; i++)
{
ans += min(ti[i] - ti[i - 1],t);
}
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:8:20: error: 'i' was not declared in this scope; did you mean 'ti'?
8 | vector<int> ti(i);
| ^
| ti
|
s645492198 | p03733 | C++ | #include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x) (int)x.size()
#define SP(x) setprecision((int)x)
using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数
//-------------------------------------------------
//
void yes(){
cout <<"Yes"<<endl ;
}
void no(){
cout <<"No"<<endl ;
}
//-------------------------------------------------
// メモ
//-------------------------------------------------
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
int n ;
cin >> n ;
ll t ;
cin >> t ;
vector<ll> tim(n) ;
ll ans = 10 ;
REP(i,n){
cin >> tim.at(i) ;
}
REP(i,n){
if(i!=0){
if(tim.at(i)<=t+t.at(i-1)){
ans += t.at(i)-t.at(i-1) ;
}
else{
ans += t ;
}
}
}
cout <<ans <<endl ;
return 0 ;
}
| a.cc: In function 'int main()':
a.cc:63:25: error: request for member 'at' in 't', which is of non-class type 'll' {aka 'long long int'}
63 | if(tim.at(i)<=t+t.at(i-1)){
| ^~
a.cc:64:18: error: request for member 'at' in 't', which is of non-class type 'll' {aka 'long long int'}
64 | ans += t.at(i)-t.at(i-1) ;
| ^~
a.cc:64:26: error: request for member 'at' in 't', which is of non-class type 'll' {aka 'long long int'}
64 | ans += t.at(i)-t.at(i-1) ;
| ^~
|
s708638544 | p03733 | C++ | #include<bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
ll n,t;
cin>>n>>t;
vll a(n);
ll ans=0;
rep(i,n) cin>>a[i];
fpr(int i=1;i<n;i++){
if(a[i]-a[i-1]<t){
ans+=a[i]-a[i-1];
}
else{
ans+=t;
}
}
ans+=t;
COUT(ans);
} | a.cc: In function 'int main()':
a.cc:39:7: error: expected primary-expression before 'int'
39 | fpr(int i=1;i<n;i++){
| ^~~
a.cc:39:15: error: 'i' was not declared in this scope
39 | fpr(int i=1;i<n;i++){
| ^
|
s325707908 | p03733 | Java | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N=sc.nextInt();
int T=sc.nextInt();
int[] t=new int[N];
int ans = 0;
for(int i=0;i<N;i++){
t[i]=sc.nextInt();
}
if(N > 1){
ans = t[1] - t[0];
}else{
ans = T;
System.out.println(ans);
break;
}
for(int j=1;j<N;j++){
if(T <(t[j+1] - t[j])){
ans += (t[j+1] - t[j]);
}else{
ans += T;
}
}
ans += T;
System.out.println(ans);
}
} | Main.java:20: error: break outside switch or loop
break;
^
1 error
|
s594998029 | p03733 | Java | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N=sc.nextInt();
int T=sc.nextInt();
int[] t=new int[N];
int ans = T;
for(int i=0;i<N;i++){
t[i]=sc.nextInt();
}
for(int j=1;j<n;j++){
if(T <(t[j] - t[j-1])){
ans += t[j] - t[j-1];
}else{
ans += T;
}
}
System.out.println(ans);
}
} | Main.java:15: error: cannot find symbol
for(int j=1;j<n;j++){
^
symbol: variable n
location: class Main
1 error
|
s594612617 | p03733 | C++ | #include <iostream>
#include "cstdio"
using namespace std;
const int maxn = 200005;
int n, tx[maxn];
int clk, cur;
int sum, u, t;
int main()
{
scanf("%d %d", &n, &t);
clk = 0;cur = 0;
for(int i = 1; i <= n; i++)
{
scanf("%d", &tx[i]);
}
sort(tx+1, tx+1+n);
long long ans = 0;
for(int i = 1; i <= n; i++)
{
ans += tx[i] + t - max(tx[i], cur);
cur = tx[i] + t;
}
/* if(u - cur > t || cur == 0) clk = 0;
else clk = 1;
if(clk)
sum += u - cur;
else
sum += t;
cur = u;
*/
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:16:9: error: 'sort' was not declared in this scope; did you mean 'short'?
16 | sort(tx+1, tx+1+n);
| ^~~~
| short
|
s997002413 | p03733 | C++ | #include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=2e6+5;
long long a[maxn];
int main()
{
int n;
long long m;
scanf("%d %lld",&n,&t);
for(int i=1;i<=n;i++){
scanf("%lld",&a[i]);
}
long long x=0;
for(int i=2;i<=n;i++){
if(a[i]-a[i-1]<t)
x=x+a[i]-a[i-1];
else
x=x+t;
}
x=x+t;
printf("%lld\n",x);
}
| a.cc: In function 'int main()':
a.cc:10:29: error: 't' was not declared in this scope
10 | scanf("%d %lld",&n,&t);
| ^
|
s028042892 | p03733 | C++ | #include<bits/stdc++.h>
using namespace std;
int n,w;
int arr[100][2];
int dp[100][101][300];
int w1;
int get(int cur,int num,int a){
if(cur==n)return 0;
if(dp[cur][num][a]>=0) return dp[cur][num][a];
int remain=w-w1*num-a;
int res=get(cur+1,num,a);
if(remain>=arr[cur][0])
res=max(res,arr[cur][1]+get(cur+1,num+1,a+(arr[cur][0]-w1)));
return dp[cur][num][a]=res;
}
int main(void){
cin >> n >> w;
for(int i=0;i<n;i++)
cin >> arr[i][0] >> arr[i][1];
w1=arr[i][0];
memset(dp,-1,sizeof(dp));
cout <<get(0,0,0);
}
| a.cc: In function 'int main()':
a.cc:20:9: error: 'i' was not declared in this scope
20 | w1=arr[i][0];
| ^
|
s340382897 | p03733 | C++ | a,b = map(int,input().split())
ls = list(map(int, input().split()))
duration = 0
max = 0
for i in ls :
if i <= max and max <= i+b :
duration += i + b - max
max = i + b
elif max < i :
duration += b
max = i + b
print(duration) | a.cc:1:1: error: 'a' does not name a type
1 | a,b = map(int,input().split())
| ^
|
s545725149 | p03733 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;
// int INT_MAX = 2000000000;
namespace __output {
template<class T1, class T2> void pr(const pair<T1,T2>& x);
template<class T, size_t SZ> void pr(const array<T,SZ>& x);
template<class T> void pr(const vector<T>& x);
template<class T> void pr(const set<T>& x);
template<class T1, class T2> void pr(const map<T1,T2>& x);
template<class T> void pr(const T& x) { cout << x; }
template<class Arg, class... Args> void pr(const Arg& first, const Args&... rest) {
pr(first); pr(rest...);
}
template<class T1, class T2> void pr(const pair<T1,T2>& x) {
pr("{",x.first,", ",x.second,"}");
}
template<class T, bool pretty = true> void prContain(const T& x) {
if (pretty) pr("{");
bool fst = 1; for (const auto& a: x) pr(!fst?pretty?", ":" ":"",a), fst = 0;
if (pretty) pr("}");
}
template<class T> void pc(const T& x) { prContain<T, false>(x); pr("\n"); }
template<class T, size_t SZ> void pr(const array<T,SZ>& x) { prContain(x); }
template<class T> void pr(const vector<T>& x) { prContain(x); }
template<class T> void pr(const set<T>& x) { prContain(x); }
template<class T1, class T2> void pr(const map<T1,T2>& x) { prContain(x); }
void ps() { pr("\n"); }
template<class Arg> void ps(const Arg& first) {
pr(first); ps();
}
template<class Arg, class... Args> void ps(const Arg& first, const Args&... rest) {
pr(first," "); ps(rest...);
}
}
using namespace __output;
#define TRACE(x) x
#define __pn(x) pr(#x, " = ")
#define pd(...) __pn((__VA_ARGS__)), ps(__VA_ARGS__), cout << flush
struct ball {
int bag_idx;
int ball_idx;
int value;
friend ostream& operator<<(ostream& os, const ball& b) {
os << "{" << b.bag_idx << ", " << b.ball_idx << ", " << b.value << "}";
return os;
}
};
struct bag {
int a;
int b;
int a_gidx;
int b_gidx;
friend ostream& operator<<(ostream& os, const bag& b) {
os << "{" << b.a << ", " << b.b << ", " << b.a_gidx << ", " << b.b_gidx << "}";
return os;
}
};
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int N;
cin >> N;
vector<bag> bags(N);
vector<ball> balls(2 * N);
long long initial_product;
int global_min = INT_MAX;
int global_max = 0;
int largest_red = 0;
int smallest_blue = INT_MAX;
for (int i = 0; i < N; i++) {
int a, b;
cin >> a >> b;
bags[i] = a < b ? bag{a, b} : bag{b, a};
int lower = bags[i].a;
int upper = bags[i].b;
largest_red = max(largest_red, lower);
smallest_blue = min(smallest_blue, upper);
global_min = min(global_min, lower);
global_max = max(global_max, upper);
balls[2 * i] = ball{i, 0, bags[i].a};
balls[2 * i + 1] = ball{i, 1, bags[i].b};
}
initial_product = (long long)(global_max - smallest_blue) * (long long)(largest_red - global_min);
sort(
balls.begin(),
balls.end(),
[](ball b1, ball b2) { return b1.value < b2.value; }
);
for (int i = 0; i < balls.size(); i++) {
int bag_idx = balls[i].bag_idx;
if (balls[i].ball_idx) {
bags[bag_idx].b_gidx = i;
}
else {
bags[bag_idx].a_gidx = i;
}
}
map<int, int> blues;
map<int, int> reds;
int global_max_idx = balls[2 * N - 1].bag_idx;
blues[global_max_idx] = 1;
reds[global_max_idx] = 0;
int global_min_idx = balls[0].bag_idx;
blues[global_min_idx] = 0;
reds[global_min_idx] = 1;
map<int, int> reds2 = reds;
int r_max_idx_bound;
for (int i = 2 * N - 2; i > 0; i--) {
ball bal = balls[i];
if (reds2.count(bal.bag_idx)) {
if (bal.bag_idx == global_min_idx or bal.bag_idx == global_max_idx) {
r_max_idx_bound = i;
}
else { r_max_idx_bound = i + 1; }
break;
}
reds2[bal.bag_idx] = bool(bal.ball_idx);
}
pd(r_max_idx_bound);
int cur_r_min;
for (int i = 1; i < 2 * N; i++) {
int bag_idx = balls[i].bag_idx;
if (reds.count(bag_idx)) {
cur_r_min = i;
break;
}
reds[bag_idx] = 1;
blues[bag_idx] = 0;
}
pd(cur_r_min);
pd(bags);
int smallest_diff = INT_MAX;
for (int i = 2 * N - 2; i >= r_max_idx_bound; i--) {
int bag_idx = balls[i].bag_idx;
pd(balls[i]);
if (!reds.count(bag_idx)) {
reds[bag_idx] = 1;
blues[bag_idx] = 0;
}
pd(cur_r_min);
pd(blues);
pd(reds);
smallest_diff = min(smallest_diff, balls[i].value - balls[cur_r_min].value);
if (i == r_max_idx_bound) break;
cur_r_min = min(cur_r_min, bags[bag_idx].a_gidx);
blues[bag_idx] = 1;
reds[bag_idx] = 0;
}
long long new_product = (long long)smallest_diff * (long long)(global_max - global_min);
pd(initial_product);
pd(new_product);
pd(balls);
cout << min(initial_product, new_product) << "\n";
return 0;
}
| a.cc: In function 'int main()':
a.cc:87:22: error: 'INT_MAX' was not declared in this scope
87 | int global_min = INT_MAX;
| ^~~~~~~
a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
5 | #include <set>
+++ |+#include <climits>
6 | using namespace std;
|
s356956137 | p03733 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
using namespace std;
INT_MAX = 2000000000;
namespace __output {
template<class T1, class T2> void pr(const pair<T1,T2>& x);
template<class T, size_t SZ> void pr(const array<T,SZ>& x);
template<class T> void pr(const vector<T>& x);
template<class T> void pr(const set<T>& x);
template<class T1, class T2> void pr(const map<T1,T2>& x);
template<class T> void pr(const T& x) { cout << x; }
template<class Arg, class... Args> void pr(const Arg& first, const Args&... rest) {
pr(first); pr(rest...);
}
template<class T1, class T2> void pr(const pair<T1,T2>& x) {
pr("{",x.first,", ",x.second,"}");
}
template<class T, bool pretty = true> void prContain(const T& x) {
if (pretty) pr("{");
bool fst = 1; for (const auto& a: x) pr(!fst?pretty?", ":" ":"",a), fst = 0;
if (pretty) pr("}");
}
template<class T> void pc(const T& x) { prContain<T, false>(x); pr("\n"); }
template<class T, size_t SZ> void pr(const array<T,SZ>& x) { prContain(x); }
template<class T> void pr(const vector<T>& x) { prContain(x); }
template<class T> void pr(const set<T>& x) { prContain(x); }
template<class T1, class T2> void pr(const map<T1,T2>& x) { prContain(x); }
void ps() { pr("\n"); }
template<class Arg> void ps(const Arg& first) {
pr(first); ps();
}
template<class Arg, class... Args> void ps(const Arg& first, const Args&... rest) {
pr(first," "); ps(rest...);
}
}
using namespace __output;
#define TRACE(x) x
#define __pn(x) pr(#x, " = ")
#define pd(...) __pn((__VA_ARGS__)), ps(__VA_ARGS__), cout << flush
struct ball {
int bag_idx;
int ball_idx;
int value;
friend ostream& operator<<(ostream& os, const ball& b) {
os << "{" << b.bag_idx << ", " << b.ball_idx << ", " << b.value << "}";
return os;
}
};
struct bag {
int a;
int b;
int a_gidx;
int b_gidx;
friend ostream& operator<<(ostream& os, const bag& b) {
os << "{" << b.a << ", " << b.a << ", " << b.a_gidx << ", " << b.b_gidx << "}";
return os;
}
};
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int N;
cin >> N;
vector<bag> bags(N);
vector<ball> balls(2 * N);
long long initial_product;
int global_min = INT_MAX;
int global_max = 0;
int largest_red = 0;
int smallest_blue = INT_MAX;
for (int i = 0; i < N; i++) {
int a, b;
cin >> a >> b;
bags[i] = a < b ? bag{a, b} : bag{b, a};
int lower = bags[i].a;
int upper = bags[i].b;
largest_red = max(largest_red, lower);
smallest_blue = min(smallest_blue, upper);
global_min = min(global_min, lower);
global_max = max(global_max, upper);
balls[2 * i] = ball{i, 0, bags[i].a};
balls[2 * i + 1] = ball{i, 1, bags[i].b};
}
initial_product = (long long)(global_max - smallest_blue) * (long long)(largest_red - global_min);
sort(
balls.begin(),
balls.end(),
[](ball b1, ball b2) { return b1.value < b2.value; }
);
for (int i = 0; i < balls.size(); i++) {
int bag_idx = balls[i].bag_idx;
if (balls[i].ball_idx) {
bags[bag_idx].b_gidx = i;
}
else {
bags[bag_idx].a_gidx = i;
}
}
map<int, int> blues;
map<int, int> reds;
int global_max_idx = balls[2 * N - 1].bag_idx;
blues[global_max_idx] = 1;
reds[global_max_idx] = 0;
int global_min_idx = balls[0].bag_idx;
blues[global_min_idx] = 0;
reds[global_min_idx] = 1;
map<int, int> reds2 = reds;
int r_max_idx_bound;
for (int i = 2 * N - 2; i > 0; i--) {
ball bal = balls[i];
if (reds2.count(bal.bag_idx)) {
if (bal.bag_idx == global_min_idx or bal.bag_idx == global_max_idx) {
r_max_idx_bound = i;
}
else { r_max_idx_bound = i + 1; }
break;
}
reds2[bal.bag_idx] = bool(bal.ball_idx);
}
int cur_r_min;
for (int i = 1; i < 2 * N; i++) {
int bag_idx = balls[i].bag_idx;
if (reds.count(bag_idx)) {
cur_r_min = i;
break;
}
reds[bag_idx] = 1;
blues[bag_idx] = 0;
}
int smallest_diff = INT_MAX;
for (int i = 2 * N - 2; i >= r_max_idx_bound; i--) {
int bag_idx = balls[i].bag_idx;
if (!reds.count(bag_idx)) {
reds[bag_idx] = 1;
blues[bag_idx] = 0;
}
smallest_diff = min(smallest_diff, balls[i].value - balls[cur_r_min].value);
if (i == r_max_idx_bound) break;
cur_r_min = min(cur_r_min, bags[i].a_gidx);
blues[bag_idx] = 1;
reds[bag_idx] = 0;
}
long long new_product = (long long)smallest_diff * (long long)(global_max - global_min);
cout << min(initial_product, new_product) << "\n";
return 0;
}
| a.cc:8:1: error: 'INT_MAX' does not name a type
8 | INT_MAX = 2000000000;
| ^~~~~~~
a.cc:6:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
5 | #include <set>
+++ |+#include <climits>
6 | using namespace std;
a.cc: In function 'int main()':
a.cc:87:22: error: 'INT_MAX' was not declared in this scope
87 | int global_min = INT_MAX;
| ^~~~~~~
a.cc:87:22: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
|
s389301401 | p03733 | C | s,t,p,T;main(i){for(;~scanf("%d",&t);i--?(s+=t-p>T?T:t-p,p=t):T=t);printf("%d",s+T);} | main.c:1:1: warning: data definition has no type or storage class
1 | s,t,p,T;main(i){for(;~scanf("%d",&t);i--?(s+=t-p>T?T:t-p,p=t):T=t);printf("%d",s+T);}
| ^
main.c:1:1: error: type defaults to 'int' in declaration of 's' [-Wimplicit-int]
main.c:1:3: error: type defaults to 'int' in declaration of 't' [-Wimplicit-int]
1 | s,t,p,T;main(i){for(;~scanf("%d",&t);i--?(s+=t-p>T?T:t-p,p=t):T=t);printf("%d",s+T);}
| ^
main.c:1:5: error: type defaults to 'int' in declaration of 'p' [-Wimplicit-int]
1 | s,t,p,T;main(i){for(;~scanf("%d",&t);i--?(s+=t-p>T?T:t-p,p=t):T=t);printf("%d",s+T);}
| ^
main.c:1:7: error: type defaults to 'int' in declaration of 'T' [-Wimplicit-int]
1 | s,t,p,T;main(i){for(;~scanf("%d",&t);i--?(s+=t-p>T?T:t-p,p=t):T=t);printf("%d",s+T);}
| ^
main.c:1:9: error: return type defaults to 'int' [-Wimplicit-int]
1 | s,t,p,T;main(i){for(;~scanf("%d",&t);i--?(s+=t-p>T?T:t-p,p=t):T=t);printf("%d",s+T);}
| ^~~~
main.c: In function 'main':
main.c:1:9: error: type of 'i' defaults to 'int' [-Wimplicit-int]
main.c:1:23: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
1 | s,t,p,T;main(i){for(;~scanf("%d",&t);i--?(s+=t-p>T?T:t-p,p=t):T=t);printf("%d",s+T);}
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 | s,t,p,T;main(i){for(;~scanf("%d",&t);i--?(s+=t-p>T?T:t-p,p=t):T=t);printf("%d",s+T);}
main.c:1:23: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
1 | s,t,p,T;main(i){for(;~scanf("%d",&t);i--?(s+=t-p>T?T:t-p,p=t):T=t);printf("%d",s+T);}
| ^~~~~
main.c:1:23: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:1:64: error: lvalue required as left operand of assignment
1 | s,t,p,T;main(i){for(;~scanf("%d",&t);i--?(s+=t-p>T?T:t-p,p=t):T=t);printf("%d",s+T);}
| ^
main.c:1:68: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
1 | s,t,p,T;main(i){for(;~scanf("%d",&t);i--?(s+=t-p>T?T:t-p,p=t):T=t);printf("%d",s+T);}
| ^~~~~~
main.c:1:68: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:1:68: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:1:68: note: include '<stdio.h>' or provide a declaration of 'printf'
|
s006192515 | p03733 | C | s,t,p,T;main(i){for(;~scanf("%d",&t);i--?s+=t-p>T?T:t-p,p=t:T=t);printf("%d",s+T);} | main.c:1:1: warning: data definition has no type or storage class
1 | s,t,p,T;main(i){for(;~scanf("%d",&t);i--?s+=t-p>T?T:t-p,p=t:T=t);printf("%d",s+T);}
| ^
main.c:1:1: error: type defaults to 'int' in declaration of 's' [-Wimplicit-int]
main.c:1:3: error: type defaults to 'int' in declaration of 't' [-Wimplicit-int]
1 | s,t,p,T;main(i){for(;~scanf("%d",&t);i--?s+=t-p>T?T:t-p,p=t:T=t);printf("%d",s+T);}
| ^
main.c:1:5: error: type defaults to 'int' in declaration of 'p' [-Wimplicit-int]
1 | s,t,p,T;main(i){for(;~scanf("%d",&t);i--?s+=t-p>T?T:t-p,p=t:T=t);printf("%d",s+T);}
| ^
main.c:1:7: error: type defaults to 'int' in declaration of 'T' [-Wimplicit-int]
1 | s,t,p,T;main(i){for(;~scanf("%d",&t);i--?s+=t-p>T?T:t-p,p=t:T=t);printf("%d",s+T);}
| ^
main.c:1:9: error: return type defaults to 'int' [-Wimplicit-int]
1 | s,t,p,T;main(i){for(;~scanf("%d",&t);i--?s+=t-p>T?T:t-p,p=t:T=t);printf("%d",s+T);}
| ^~~~
main.c: In function 'main':
main.c:1:9: error: type of 'i' defaults to 'int' [-Wimplicit-int]
main.c:1:23: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
1 | s,t,p,T;main(i){for(;~scanf("%d",&t);i--?s+=t-p>T?T:t-p,p=t:T=t);printf("%d",s+T);}
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 | s,t,p,T;main(i){for(;~scanf("%d",&t);i--?s+=t-p>T?T:t-p,p=t:T=t);printf("%d",s+T);}
main.c:1:23: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
1 | s,t,p,T;main(i){for(;~scanf("%d",&t);i--?s+=t-p>T?T:t-p,p=t:T=t);printf("%d",s+T);}
| ^~~~~
main.c:1:23: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:1:62: error: lvalue required as left operand of assignment
1 | s,t,p,T;main(i){for(;~scanf("%d",&t);i--?s+=t-p>T?T:t-p,p=t:T=t);printf("%d",s+T);}
| ^
main.c:1:66: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
1 | s,t,p,T;main(i){for(;~scanf("%d",&t);i--?s+=t-p>T?T:t-p,p=t:T=t);printf("%d",s+T);}
| ^~~~~~
main.c:1:66: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:1:66: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:1:66: note: include '<stdio.h>' or provide a declaration of 'printf'
|
s147461987 | p03733 | C++ | #include<iostream>
#include<vector>
using namespace std;
int main(){
int N,T,sum=0;
cin >> N >> T;
vector<int> t(N);
for(int i=0;i<N;i++){
cin << t[i];
}
for(int j=1;j<N;j++){
if(t[j]-t[j-1]<T){
sum += t[j]-t[j-1];
}else{
sum += T;
}
}
} | a.cc: In function 'int main()':
a.cc:11:9: error: no match for 'operator<<' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
11 | cin << t[i];
a.cc:11:9: note: candidate: 'operator<<(int, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int})' (built-in)
a.cc:11:9: note: no known conversion for argument 1 from 'std::istream' {aka 'std::basic_istream<char>'} to 'int'
In file included from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/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/string_view:763:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, basic_string_view<_CharT, _Traits>)'
763 | operator<<(basic_ostream<_CharT, _Traits>& __os,
| ^~~~~~~~
/usr/include/c++/14/string_view:763:5: note: template argument deduction/substitution failed:
a.cc:11:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
11 | cin << t[i];
| ^
/usr/include/c++/14/bits/basic_string.h:4077:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)'
4077 | operator<<(basic_ostream<_CharT, _Traits>& __os,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:4077:5: note: template argument deduction/substitution failed:
a.cc:11:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
11 | cin << t[i];
| ^
In file included from /usr/include/c++/14/bits/memory_resource.h:38,
from /usr/include/c++/14/string:68:
/usr/include/c++/14/cstddef:125:5: note: candidate: 'template<class _IntegerType> constexpr std::__byte_op_t<_IntegerType> std::operator<<(byte, _IntegerType)'
125 | operator<<(byte __b, _IntegerType __shift) noexcept
| ^~~~~~~~
/usr/include/c++/14/cstddef:125:5: note: template argument deduction/substitution failed:
a.cc:11:5: note: cannot convert 'std::cin' (type 'std::istream' {aka 'std::basic_istream<char>'}) to type 'std::byte'
11 | cin << t[i];
| ^~~
In file included from /usr/include/c++/14/bits/ios_base.h:46:
/usr/include/c++/14/system_error:339:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const error_code&)'
339 | operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e)
| ^~~~~~~~
/usr/include/c++/14/system_error:339:5: note: template argument deduction/substitution failed:
a.cc:11:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
11 | cin << t[i];
| ^
/usr/include/c++/14/ostream:563:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, _CharT)'
563 | operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)
| ^~~~~~~~
/usr/include/c++/14/ostream:563:5: note: template argument deduction/substitution failed:
a.cc:11:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
11 | cin << t[i];
| ^
/usr/include/c++/14/ostream:573:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, char)'
573 | operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)
| ^~~~~~~~
/usr/include/c++/14/ostream:573:5: note: template argument deduction/substitution failed:
a.cc:11:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
11 | cin << t[i];
| ^
/usr/include/c++/14/ostream:579:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, char)'
579 | operator<<(basic_ostream<char, _Traits>& __out, char __c)
| ^~~~~~~~
/usr/include/c++/14/ostream:579:5: note: template argument deduction/substitution failed:
a.cc:11:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>'
11 | cin << t[i];
| ^
/usr/include/c++/14/ostream:590:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, signed char)'
590 | operator<<(basic_ostream<char, _Traits>& __out, signed char __c)
| ^~~~~~~~
/usr/include/c++/14/ostream:590:5: note: template argument deduction/substitution failed:
a.cc:11:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>'
11 | cin << t[i];
| ^
/usr/include/c++/14/ostream:595:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, unsigned char)'
595 | operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)
| ^~~~~~~~
/usr/include/c++/14/ostream:595:5: note: template argument deduction/substitution failed:
a.cc:11:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>'
11 | cin << t[i];
| ^
/usr/include/c++/14/ostream:654:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const _CharT*)'
654 | operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)
| ^~~~~~~~
/usr/include/c++/14/ostream:654:5: note: template argument deduction/substitution failed:
a.cc:11:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
11 | cin << t[i];
| ^
In file included from /usr/include/c++/14/ostream:1022:
/usr/include/c++/14/bits/ostream.tcc:307:5: note: candidate: 'template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(basic_ostream<_CharT, _Traits>&, const char*)'
307 | operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)
| ^~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:307:5: note: template argument deduction/substitution failed:
a.cc:11:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<_CharT, _Traits>'
11 | cin << t[i];
| ^
/usr/include/c++/14/ostream:671:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const char*)'
671 | operator<<(basic_ostream<char, _Traits>& __out, const char* __s)
| ^~~~~~~~
/usr/include/c++/14/ostream:671:5: note: template argument deduction/substitution failed:
a.cc:11:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>'
11 | cin << t[i];
| ^
/usr/include/c++/14/ostream:684:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const signed char*)'
684 | operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)
| ^~~~~~~~
/usr/include/c++/14/ostream:684:5: note: template argument deduction/substitution failed:
a.cc:11:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>'
11 | cin << t[i];
| ^
/usr/include/c++/14/ostream:689:5: note: candidate: 'template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(basic_ostream<char, _Traits>&, const unsigned char*)'
689 | operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)
| ^~~~~~~~
/usr/include/c++/14/ostream:689:5: note: template argument deduction/substitution failed:
a.cc:11:15: note: 'std::istream' {aka 'std::basic_istream<char>'} is not derived from 'std::basic_ostream<char, _Traits>'
11 | cin << t[i];
| ^
/usr/include/c++/14/ostream:810:5: note: candidate: 'template<class _Ostream, class _Tp> _Ostream&& std::operator<<(_Ostream&&, const _Tp&)'
810 | operator<<(_Ostream&& __os, const _Tp& __x)
| ^~~~~~~~
/usr/include/c++/14/ostream:810:5: note: template argument deduction/substitution failed:
/usr/include/c++/14/ostream: In substitution of 'template<class _Ostream, class _Tp> _Ostream&& std::operator<<(_Ostream&&, const _Tp&) [with _Ostream = std::basic_istream<char>&; _Tp = int]':
a.cc:11:15: required from here
11 | cin << t[i];
| ^
/usr/include/c++/14/ostream:810:5: error: no type named 'type' in 'struct std::enable_if<false, void>'
810 | operator<<(_Ostream&& __os, const _Tp& __x)
| ^~~~~~~~
|
s162952958 | p03733 | C++ | #include<iostream>
#include<vector>
using namespace std;
int main(){
int N,T,sum=0;
cin >> N >> T;
vector(int) t(N);
for(int i=0;i<N;i++){
cin << t[i];
}
for(int j=1;j<N;j++){
if(t[j]-t[j-1]<T){
sum += t[j]-t[j-1];
}else{
sum += T;
}
}
}
| a.cc: In function 'int main()':
a.cc:9:9: error: missing template arguments before '(' token
9 | vector(int) t(N);
| ^
a.cc:9:10: error: expected primary-expression before 'int'
9 | vector(int) t(N);
| ^~~
a.cc:11:12: error: 't' was not declared in this scope
11 | cin << t[i];
| ^
a.cc:14:8: error: 't' was not declared in this scope
14 | if(t[j]-t[j-1]<T){
| ^
|
s785337229 | p03733 | C++ | #pragma region includes, macros
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef int64_t i64;
typedef pair<i64, i64> P;
template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};
struct edge {
i64 from, to, cost;
edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};
// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
for (auto& e : t) fill_v(e, v);
}
//
#pragma endregion
int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
int main() {
i64 n, t;
cin >> n >> t;
vector<i64> a(n);
for(int i = 0; i < n; ++i) cin >> a[i];
i64 ans = 0;
i64 pre = -1 * t;
for(int i = 0; i < n; ++i){
ans += t - max(0, pre - a[i]);
pre = a[i] + t;
}
cout << ans << endl;
}
| a.cc:24:15: error: 'numeric_limits' was not declared in this scope
24 | const T INF = numeric_limits<T>::max();
| ^~~~~~~~~~~~~~
a.cc:24:31: error: expected primary-expression before '>' token
24 | const T INF = numeric_limits<T>::max();
| ^
a.cc:24:37: error: no matching function for call to 'max()'
24 | const T INF = numeric_limits<T>::max();
| ~~~~~^~
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: candidate expects 2 arguments, 0 provided
/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, 0 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, 0 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: candidate expects 2 arguments, 0 provided
a.cc:26:16: error: 'numeric_limits' was not declared in this scope
26 | const T SINF = numeric_limits<T>::max() / 10;
| ^~~~~~~~~~~~~~
a.cc:26:32: error: expected primary-expression before '>' token
26 | const T SINF = numeric_limits<T>::max() / 10;
| ^
a.cc:26:38: error: no matching function for call to 'max()'
26 | const T SINF = numeric_limits<T>::max() / 10;
| ~~~~~^~
/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: candidate expects 2 arguments, 0 provided
/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, 0 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, 0 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: candidate expects 2 arguments, 0 provided
a.cc: In function 'int main()':
a.cc:72:23: error: no matching function for call to 'max(int, i64)'
72 | ans += t - max(0, pre - a[i]);
| ~~~^~~~~~~~~~~~~~~
/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:72:23: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'i64' {aka 'long int'})
72 | ans += t - max(0, pre - 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
/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:72:23: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
72 | ans += t - max(0, pre - a[i]);
| ~~~^~~~~~~~~~~~~~~
|
s957631430 | p03733 | C++ | #pragma region includes, macros
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef int64_t i64;
typedef pair<i64, i64> P;
template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};
struct edge {
i64 from, to, cost;
edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};
// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
for (auto& e : t) fill_v(e, v);
}
//
#pragma endregion
int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
int main() {
i64 n, t;
cin >> n >> t;
vector<i64> a(n);
for(int i = 0; i < n; ++i) cin >> a[i];
i64 ans = 0;
i64 pre = -1 * t;
for(int i = 0; i < n; ++i){
ans += t - max(0LL, pre - a[i]);
pre = a[i] + t;
}
cout << ans << endl;
}
| a.cc:24:15: error: 'numeric_limits' was not declared in this scope
24 | const T INF = numeric_limits<T>::max();
| ^~~~~~~~~~~~~~
a.cc:24:31: error: expected primary-expression before '>' token
24 | const T INF = numeric_limits<T>::max();
| ^
a.cc:24:37: error: no matching function for call to 'max()'
24 | const T INF = numeric_limits<T>::max();
| ~~~~~^~
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: candidate expects 2 arguments, 0 provided
/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, 0 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, 0 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: candidate expects 2 arguments, 0 provided
a.cc:26:16: error: 'numeric_limits' was not declared in this scope
26 | const T SINF = numeric_limits<T>::max() / 10;
| ^~~~~~~~~~~~~~
a.cc:26:32: error: expected primary-expression before '>' token
26 | const T SINF = numeric_limits<T>::max() / 10;
| ^
a.cc:26:38: error: no matching function for call to 'max()'
26 | const T SINF = numeric_limits<T>::max() / 10;
| ~~~~~^~
/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: candidate expects 2 arguments, 0 provided
/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, 0 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, 0 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: candidate expects 2 arguments, 0 provided
a.cc: In function 'int main()':
a.cc:72:23: error: no matching function for call to 'max(long long int, i64)'
72 | ans += t - max(0LL, pre - a[i]);
| ~~~^~~~~~~~~~~~~~~~~
/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:72:23: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'i64' {aka 'long int'})
72 | ans += t - max(0LL, pre - 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
/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:72:23: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
72 | ans += t - max(0LL, pre - a[i]);
| ~~~^~~~~~~~~~~~~~~~~
|
s778375302 | p03733 | C++ | #pragma region includes, macros
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef int64_t i64;
typedef pair<i64, i64> P;
template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};
struct edge {
i64 from, to, cost;
edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};
// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
for (auto& e : t) fill_v(e, v);
}
//
#pragma endregion
int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
int main() {
i64 n, t;
cin >> n >> t;
vector<i64> a(n);
for(int i = 0; i < n; ++i) cin >> a[i];
i64 ans = 0;
i64 pre = -1 * t;
for(int i = 0; i < n; ++i){
ans += t - max(0LL, pre - a[i]);
pre = a[i] + t;
}
cout << ans << endl;
}
| a.cc:24:15: error: 'numeric_limits' was not declared in this scope
24 | const T INF = numeric_limits<T>::max();
| ^~~~~~~~~~~~~~
a.cc:24:31: error: expected primary-expression before '>' token
24 | const T INF = numeric_limits<T>::max();
| ^
a.cc:24:37: error: no matching function for call to 'max()'
24 | const T INF = numeric_limits<T>::max();
| ~~~~~^~
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: candidate expects 2 arguments, 0 provided
/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, 0 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, 0 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: candidate expects 2 arguments, 0 provided
a.cc:26:16: error: 'numeric_limits' was not declared in this scope
26 | const T SINF = numeric_limits<T>::max() / 10;
| ^~~~~~~~~~~~~~
a.cc:26:32: error: expected primary-expression before '>' token
26 | const T SINF = numeric_limits<T>::max() / 10;
| ^
a.cc:26:38: error: no matching function for call to 'max()'
26 | const T SINF = numeric_limits<T>::max() / 10;
| ~~~~~^~
/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: candidate expects 2 arguments, 0 provided
/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, 0 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, 0 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: candidate expects 2 arguments, 0 provided
a.cc: In function 'int main()':
a.cc:72:23: error: no matching function for call to 'max(long long int, i64)'
72 | ans += t - max(0LL, pre - a[i]);
| ~~~^~~~~~~~~~~~~~~~~
/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:72:23: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'i64' {aka 'long int'})
72 | ans += t - max(0LL, pre - 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
/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:72:23: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
72 | ans += t - max(0LL, pre - a[i]);
| ~~~^~~~~~~~~~~~~~~~~
|
s222978392 | p03733 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
int main(){
ll N,T;
cin>>N>>T;
vll t(N);
for (ll i=0;i<N;i++) cin>>t[i];
ans=T;
for (ll i=0;i<N-1;i++) {
ll x=t[i]+T-t[i+1];
ans += T-max((ll)0,x);
}
cout<<ans;
} | a.cc: In function 'int main()':
a.cc:10:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
10 | ans=T;
| ^~~
| abs
|
s603501064 | p03733 | Java | public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n=sc.nextInt();
long t=sc.nextInt();
long[] nums=new long[n+1];
for(int i=0;i<n;i++){
nums[i]=sc.nextInt();
}
nums[n]=Long.MAX_VALUE;
long output=0;
for(int i=0;i<n;i++){
output+=Math.min(t, nums[i+1]-nums[i]);
}
System.out.println(output);
}
} | Main.java:4: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
Main.java:4: error: cannot find symbol
Scanner sc = new Scanner(System.in);
^
symbol: class Scanner
location: class Main
2 errors
|
s213012363 | p03733 | C++ | #include <tuple>
#include <random>
#include <map>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>
#include <functional>
#define REP(i,a) for(int (i)=0;(i)<(a);i++)
#define RREP(i,a,b) for(int (i)=(a);(i)<(b);i++)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<ll>
typedef long long ll;
using namespace std;
int main(void){
ll N,T,ans=0;
vll t(N);
cin>>N>>T;
REP(i,N){
cin>>t[i];
}
REP(i,N){
if(i==N-1){
ans+=T;
}else if(t[i] + T <= t[i+1]){
ans+=T;
}else{
ans += t[i+1]-t[i];
}
}
cout<<ans;
return 0;
} | a.cc: In function 'int main()':
a.cc:27:5: error: 'cin' was not declared in this scope
27 | cin>>N>>T;
| ^~~
a.cc:13:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
12 | #include <functional>
+++ |+#include <iostream>
13 |
a.cc:40:5: error: 'cout' was not declared in this scope
40 | cout<<ans;
| ^~~~
a.cc:40:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
|
s115876099 | p03733 | C++ | #include <iostream>
#include <algorithm>
using namespace std;
int main(void) {
int num, t, ans = 0, i = 1, a, b;
cin >> num >> t >> b;
for (; i < num; i++) {
scanf_s("%d", &a);
ans += min(t, a - b);
b = a;
}
cout << ans + t << "\n";
return 0;
}
| a.cc: In function 'int main()':
a.cc:10:17: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'?
10 | scanf_s("%d", &a);
| ^~~~~~~
| scanf
|
s636665660 | p03733 | 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()
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int n;
ll t;
cin >> n >> t;
vector<ll> a(n);
REP(i, n) {
cin >> a[i];
}
ll ans = t;
REP(i, n-1) {
ans += t;
if(a[i+1] - a[i] < T) ans -= t-(a[i+1] - a[i]);
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:35:24: error: 'T' was not declared in this scope
35 | if(a[i+1] - a[i] < T) ans -= t-(a[i+1] - a[i]);
| ^
|
s897110683 | p03733 | C++ | 1 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 1
| ^
|
s064462440 | p03733 | C++ | // ------------------------------------
// Date:2018/ 3/ 9
// Problem:ARC 073 Sentou c.cpp
//
// ------------------------------------
#include <bits/stdc++.h>
using namespace std;
#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl
typedef long long ll;
static const int MOD = 1000000007;
int time[101010101];
int main()
{
cin.tie(0);
ios::sync_with_stdio(false);
int N, T;
cin >> N >> T;
vector< int > t(N);
REP(i, N) {
cin >> t[i];
}
ll ans = 0ll;
REP(i, N - 1) {
ans = min(t[i + 1] - t[i], T);
}
// 最後の一回は必ずT秒出る
ans += T;
cout << ans << endl;
return 0;
}
| a.cc:23:19: error: 'int time [101010101]' redeclared as different kind of entity
23 | int time[101010101];
| ^
In file included from /usr/include/pthread.h:23,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr-default.h:35,
from /usr/include/x86_64-linux-gnu/c++/14/bits/gthr.h:157,
from /usr/include/c++/14/ext/atomicity.h:35,
from /usr/include/c++/14/bits/ios_base.h:39,
from /usr/include/c++/14/streambuf:43,
from /usr/include/c++/14/bits/streambuf_iterator.h:35,
from /usr/include/c++/14/iterator:66,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54,
from a.cc:7:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
76 | extern time_t time (time_t *__timer) __THROW;
| ^~~~
|
s142632105 | p03733 | C | #include<cstdio>
#include<cstring>
#include<iostream>
#include<map>
#include<queue>
using namespace std;
int main(){
int a[1000];
int n,t,i,T=0;
scanf("%d%d",&n,&t);
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
for(i=1;i<n;i++){
if((a[i]-a[i-1])>=t) T=T+t;
if((a[i]-a[i-1])<t) T=T+(a[i]-a[i-1]);
}
T=T+t;
printf("%d\n",T);
}
| main.c:1:9: fatal error: cstdio: No such file or directory
1 | #include<cstdio>
| ^~~~~~~~
compilation terminated.
|
s885945980 | p03733 | C++ | #include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int N,i,T,X = 0,m,t[200005];
int a = 0,dex[200005];
scanf("%d %d",&N,&T);
for(i = 0;i < N; i++)
scanf("%d",&t[i]);
dex[0] = t[0];
for(i = 1;i < N; i++)
{
if(t[i] >= T + t[dex[a]])
{
a++;
dex[a] = i;
}
}
if(a > 1)
{
for(i = 1;i <= a; i++)
{
if(dex[i] != dex[i - 1] + 1)
{
m = dex[i] - 1;
X += t[m] + T;
}
else
X + = T;
}
}
else if(a == 1)
X = 2 * T;
else
X = T + t[N - 1];
printf("%d\n",X);
return 0;
} | a.cc: In function 'int main()':
a.cc:34:37: error: expected primary-expression before '=' token
34 | X + = T;
| ^
|
s334661923 | p03733 | C++ | #include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int N,i,T,X = 0,m,t[200005];
int a = 0,dex[200005];
scanf("%d %d",&N,&T);
for(i = 0;i < N; i++)
scanf("%d",&t[i]);
dex[0] = t[0];
for(i = 1;i < N; i++)
{
if(t[i] >= T + t[dex[a]])
{
a++;
dex[a] = i;
}
}
if(a > 1)
{
for(i = 1;i <= a; i++)
{
if(dex[i] != dex[i - 1] + 1)
{
m = dex[i] - 1;
X += t[m] + T;
}
else
X + = T;
}
}
else if(a == 1)
X = 2 * T;
else
X = T + t[N - 1];
printf("%d\n",X);
return 0;
} | a.cc: In function 'int main()':
a.cc:34:37: error: expected primary-expression before '=' token
34 | X + = T;
| ^
|
s583315687 | p03733 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=2e5+10;
int ti[MAXN];
int main(){
ll n,t;
while(cin>>n>>t){
for(int i=1;i<=n;i++) cin>>t[i];
ll sum=0;
sum+=t;
for(int i=2;i<=n;i++){
if (sum>ti[i])
sum=ti[i]+t;
else
sum+=t;
}
cout<<sum<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:9:45: error: invalid types 'll {aka long long int}[int]' for array subscript
9 | for(int i=1;i<=n;i++) cin>>t[i];
| ^
|
s896649558 | p03733 | C++ | #include<bits/stdc++.h>
using namespace std;
const int MAXN=2e5+10;
int ti[MAXN];
int main(){
int n,t;
scanf("%d%d",&n,&t);
for(int i=1;i<=n;i++) scanf("%d",&ti[i]);
ll sum=0;
sum+=t;
for(int i=2;i<=n;i++){
if (sum>ti[i])
sum=ti[i]+t;
else
sum+=t;
}
printf("%lld\n",sum);
return 0;
} | a.cc: In function 'int main()':
a.cc:9:9: error: 'll' was not declared in this scope
9 | ll sum=0;
| ^~
a.cc:10:9: error: 'sum' was not declared in this scope
10 | sum+=t;
| ^~~
|
s020145710 | p03733 | C++ | #include <iostream>
#include <algorithm>
using namespace std;
int main() {
int N, K;
cin >> N >> K;
long long prev = 0;
long long now = 0;
long long sum = 0;
for(int i = 0; i < N; ++i) {
prev = now;
cin >> now;
sum += min(now - prev, K);
}
cout << sum + K << endl;
} | a.cc: In function 'int main()':
a.cc:13:15: error: no matching function for call to 'min(long long int, int&)'
13 | sum += min(now - prev, K);
| ~~~^~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:13:15: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
13 | sum += min(now - prev, K);
| ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:13:15: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
13 | sum += min(now - prev, K);
| ~~~^~~~~~~~~~~~~~~
|
s223760808 | p03733 | C++ |
#include <set>
#include <map>
#include <cstdio>
#include <algorithm>
using namespace std;
void Get_Val(int &Ret)
{
Ret = 0;
char ch;
while (ch = getchar(), ch > '9' || ch < '0')
;
do
{
(Ret *= 10) += ch - '0';
}
while (ch = getchar(), ch >= '0' && ch <= '9');
}
const int Max_N(200050);
typedef long long int LL;
struct node
{
int X, Y;
};
int N;
LL Ans(0X3F3F3F3F3F3F3F3FLL);
node V[Max_N];
void init()
{
Get_Val(N);
for (int i = 1;i <= N;++i)
{
Get_Val(V[i].X), Get_Val(V[i].Y);
if (V[i].X > V[i].Y)
swap(V[i].X, V[i].Y);
}
}
void Task1()
{
int RMax(V[1].X), RMin(V[1].X), BMax(V[1].Y), BMin(V[1].Y);
for (int i = 2;i <= N;++i)
{
RMax = max(RMax, V[i].X), RMin = min(RMin, V[i].X);
BMax = max(BMax, V[i].Y), BMin = min(BMin, V[i].Y);
}
Ans = min(Ans, (RMax - RMin + 0LL) * (BMax - BMin + 0LL));
}
struct qwq
{
qwq(const int &_p = 0, const int &_v = 0) : p(_p), v(_v) {}
int p, v;
};
inline bool operator<(const qwq &a, const qwq &b)
{
return a.v == b.v ? a.p < b.p : a.v < b.v;
}
int Tot, All[Max_N << 1];
set<qwq> R;
set<int> L;
map< int, vector<qwq> > M;
set<qwq>::iterator Rit;
set<int>::iterator Lit;
inline int qR()
{
if (R.size())
{
Rit = R.end();
return (--Rit) -> v;
}
else
return -0X3F3F3F3F;
}
inline int qL()
{
if (L.size())
{
Lit = L.end();
return *(--Lit);
}
else
return -0X3F3F3F3F;
}
void Task2()
{
int AllMax(max(V[1].X, V[1].Y)), AllMin(min(V[1].X, V[1].Y)), YMin(V[1].Y);
for (int i = 2;i <= N;++i)
{
AllMax = max(AllMax, max(V[i].X, V[i].Y));
AllMin = min(AllMin, min(V[i].X, V[i].Y));
YMin = min(YMin, V[i].Y);
}
for (int i = 1;i <= N;++i)
All[++Tot] = V[i].X, All[++Tot] = V[i].Y, M[V[i].X].push_back(qwq(i, V[i].X)), R.insert(qwq(i, V[i].X));
sort(All + 1, All + 1 + Tot);
for (int i = 1;i <= Tot && All[i] <= YMin;++i)
{
Ans = min(Ans, (AllMax - AllMin + 0LL) * (max(qR(), qL()) - All[i] + 0LL));
if (i <= Tot && All[i + 1] != All[i])
{
vector<qwq> &vec = M[All[i]];
for (int j = 0;j != vec.size();++j)
R.erase(vec[j]), L.insert(V[vec[j].p].Y);
}
}
}
int main()
{
init();
Task1();
Task2();
printf("%lld", Ans);
return 0;
} | a.cc:69:11: error: 'vector' was not declared in this scope
69 | map< int, vector<qwq> > M;
| ^~~~~~
a.cc:6:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
5 | #include <algorithm>
+++ |+#include <vector>
6 |
a.cc:69:21: error: template argument 2 is invalid
69 | map< int, vector<qwq> > M;
| ^
a.cc:69:21: error: template argument 4 is invalid
a.cc:69:23: error: expected unqualified-id before '>' token
69 | map< int, vector<qwq> > M;
| ^
a.cc: In function 'void Task2()':
a.cc:104:59: error: 'M' was not declared in this scope
104 | All[++Tot] = V[i].X, All[++Tot] = V[i].Y, M[V[i].X].push_back(qwq(i, V[i].X)), R.insert(qwq(i, V[i].X));
| ^
a.cc:111:25: error: 'vector' was not declared in this scope
111 | vector<qwq> &vec = M[All[i]];
| ^~~~~~
a.cc:111:25: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:111:35: error: expected primary-expression before '>' token
111 | vector<qwq> &vec = M[All[i]];
| ^
a.cc:111:38: error: 'vec' was not declared in this scope
111 | vector<qwq> &vec = M[All[i]];
| ^~~
a.cc:111:44: error: 'M' was not declared in this scope
111 | vector<qwq> &vec = M[All[i]];
| ^
|
s751418903 | p03733 | C | #include <stdio.h>
#include <limits.h>
#define MAXN 200010
int t[MAXN], N, T;
int solve(void) {
int s = 0;
for(int i = 0; i < N; i++) s += min(t[i + 1] - t[i], T);
return s;
}
int main(void) {
scanf("%d%d", &N, &T);
for(int i = 0; i < N; i++) scanf("%d", &t[i]);
t[N] = INT_MAX;
printf("%d", solve());
return 0;
} | main.c: In function 'solve':
main.c:7:37: error: implicit declaration of function 'min' [-Wimplicit-function-declaration]
7 | for(int i = 0; i < N; i++) s += min(t[i + 1] - t[i], T);
| ^~~
|
s070417262 | p03733 | C++ | #include<bits/stdc++.h>
int main(int argc, const char * argv[])
{
long long pNum, baseTime, tmp, total = 0, preTmp = -1;
cin>>pNum>>baseTime;
while(pNum > 0)
{
cin>>tmp;
pNum --;
if(preTmp == -1)
{
preTmp = tmp;
continue;
}
if((preTmp + baseTime) <= tmp) total += baseTime;
else total += (tmp - preTmp);
preTmp = tmp;
}
total += baseTime;
cout<< total<<endl;
return 0;
} | a.cc: In function 'int main(int, const char**)':
a.cc:5:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
5 | cin>>pNum>>baseTime;
| ^~~
| std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146,
from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:20:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
20 | cout<< total<<endl;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:20:19: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
20 | cout<< total<<endl;
| ^~~~
| std::endl
In file included from /usr/include/c++/14/istream:41,
from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
|
s510683948 | p03733 | Java |
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.util.zip.ZipFile;
// class name example: practice_1__2017_04_16
/*
-------------------------
Summary:
Total : 4
Correct: 4
Wrong : 0
Class need to be named: Main
*/
public class Main{
// -------------------------------------------------------------------------
private final boolean debugMode = false;
private static final int[] fileTestCases = {1, 2, 3, 4};
//private final int[] fileTestCases = {0};
private int correct = 0;
private int totalTestCases = 0;
private InputReader in;
private PrintWriter out;
// -------------------------------------------------------------------------
// private void solveManyTestCasesPerFile(int fileTestCase) throws IOException { // many test cases per file
// int T = in.nextInt();
//
// for (int testNo = 1; testNo <= T; testNo++) {
//
//
//
// if (debugMode) {
// String actualResult = "'";
// assertResults(fileTestCase, testNo - 1, actualResult);
// }
// }
// }
static class Knapsack {
public static int knapSack(int W, int wt[], int val[], int n) {
int i, w;
int K[][] = new int[n + 1][W + 1];
for (i = 0; i <= n; i++) {
for (w = 0; w <= W; w++) {
if (i == 0 || w == 0)
K[i][w] = 0;
else if (wt[i - 1] <= w)
K[i][w] = Math.max(val[i - 1] + K[i - 1][w - wt[i - 1]], K[i - 1][w]);
else
K[i][w] = K[i - 1][w];
}
}
return K[n][W];
}
// public static void main(String args[])
// {
// int val[] = new int[]{60, 100, 120};
// int wt[] = new int[]{10, 20, 30};
// int W = 50;
// int n = val.length;
// System.out.println(knapSack(W, wt, val, n));
// }
}
// Your objective is to maximize the total value of the selected items.
private void solveOneTestCasePerFile(int fileTestCase) throws IOException { // 1 test case per file
int items = in.nextInt();
int targetWeight = in.nextInt();
int[] weights = new int[items];
int[] values = new int[items];
for (int i = 0; i < items; i++) {
weights[i] = in.nextInt();
values[i] = in.nextInt();
}
int ans = Knapsack.knapSack(targetWeight, weights, values, items);
System.out.println(ans);
if (debugMode) {
String actualResult = ans + "";
assertResults(fileTestCase, 0, actualResult);
}
}
// -------------------------------------------------------------------------
private void assertResults(int fileTestCase, int testNo, String actualResult) throws IOException {
if (debugMode) {
System.out.println("------------------------- Test case: " + fileTestCase);
List<String> expected;
Path zipOutPath = absTestCasePath().resolve("_" + fileTestCase + "_output.zip"); // zip
if (Files.exists(zipOutPath)) {
ZipFile zipFile = new ZipFile(zipOutPath.toFile());
InputStream stream = zipFile.getInputStream(zipFile.entries().nextElement());
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
expected = new ArrayList<>();
String line = reader.readLine();
while (line != null) {
expected.add(line);
line = reader.readLine();
}
} else {
Path outputPath = absTestCasePath().resolve("_" + fileTestCase + "_output.txt"); // txt
expected = Files.readAllLines(outputPath);
}
String expectedResult = expected.get(testNo); // assert
System.out.println("actual : " + actualResult);
System.out.println("expected: " + expectedResult);
if (!actualResult.equals(expectedResult)) {
System.out.println("test case: " + (fileTestCase) + " - wrong answer");
} else {
correct++;
}
totalTestCases++;
System.out.println("-------------------------");
}
}
private void run() throws IOException {
out = new PrintWriter(System.out);
if (debugMode) {
for (int fileTestCase : fileTestCases) {
Path zipInPath = absTestCasePath().resolve("_" + fileTestCase + "_input.zip");
if (Files.exists(zipInPath)) { // test case in zip or txt format + in + out
ZipFile zipFile = new ZipFile(zipInPath.toFile());
InputStream stream = zipFile.getInputStream(zipFile.entries().nextElement());
in = new InputReader(stream);
} else {
Path inputPath = absTestCasePath().resolve("_" + fileTestCase + "_input.txt");
in = new InputReader(new FileInputStream(inputPath.toFile()));
}
solveOneTestCasePerFile(fileTestCase);
}
System.out.println("Summary:");
System.out.println("Total : " + totalTestCases);
System.out.println("Correct: " + correct);
System.out.println("Wrong : " + (totalTestCases - correct));
} else {
in = new InputReader(System.in);
solveOneTestCasePerFile(-1);
}
}
public static void main(String[] args) throws IOException {
new Practice1__2017_05_05().run();
}
private Path absTestCasePath() {
return Paths.get(new File(getClass().getResource("").getPath().replace("target", "src"))
.getAbsolutePath()).getParent().resolve("test_cases");
}
// -------------------------------------------------------------------------
private class InputReader {
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 32768);
}
public String nextString() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public int nextInt() {
return Integer.parseInt(nextString());
}
public long nextLong() {
return Long.parseLong(nextString());
}
public double nextDouble() {
return Double.parseDouble(nextString());
}
}
}
| Main.java:163: error: cannot find symbol
new Practice1__2017_05_05().run();
^
symbol: class Practice1__2017_05_05
location: class Main
1 error
|
s459674044 | p03733 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <cstdint>
using namespace std;
int main()
{
int32_t n, t;
cin >> n >> t;
vector<int32_t> v{ n };
for(auto& x : v) {
cin >> x;
}
int64_t sum{ 0 };
for(auto i = 1U; i < v.size(); ++i) {
sum += min(t, v[i) - v[i - 1]);
}
cout << sum << endl;
}
| a.cc: In function 'int main()':
a.cc:20:26: error: expected ']' before ')' token
20 | sum += min(t, v[i) - v[i - 1]);
| ^
| ]
a.cc:20:38: error: expected ';' before ')' token
20 | sum += min(t, v[i) - v[i - 1]);
| ^
| ;
|
s053146662 | p03733 | C++ | N, T = map(int, input().split())
t = list(map(int, input().split()))
_all = N * T
sabun = 0
for i in range(1, N):
if T < t[i]:
sabun += 0
elif i == 1:
sabun += T - t[i]
else:
sabun += T - (t[i] - t[i - 1])
print(_all - sabun) | a.cc:1:1: error: 'N' does not name a type
1 | N, T = map(int, input().split())
| ^
|
s755766805 | p03733 | C++ | ////////////////////////////////////////////////////////////////////
// This source code is for Visual C++ 2010 Express
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <stack>
#include <functional>
#include <iomanip>
#include <string>
#include <cstring>
#include <deque>
#include <math.h>
#include "UnionFind.h"
#define numberof(a) (sizeof(a) / sizeof(a[0]))
#define INF (1000000)
#define Rep(i,n) for(int i = 0; i < (n); i++ )
using namespace std;
typedef vector< vector<int> > mat;
typedef pair<int, int> P;
typedef long long ll;
struct Point{
ll x;
ll y;
Point() {};
Point( ll xx, ll yy ) : x(xx), y(yy) {};
};
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
ll solve( ll N, ll T, vector<ll> & t )
{
ll ret = 0;
ll start_index = 0;
ll end_index = 0;
while(1){
ll expired = 0;
for( ll j = start_index; j < N; ++j ){
expired = (t[j] - t[start_index]);
if( expired >= T ){
end_index = j - 1;
break;
}
if( j == N - 1 ){
end_index = N - 1;
break;
}
}
ret += t[end_index] - t[start_index] + T;
// Next
start_index = end_index + 1;
if( start_index >= N ){
break;
}
}
return ret;
}
int main()
{
ll T = 0;
ll N = 0;
vector<ll> t;
cin >> N >> T;
t.resize(N);
Rep(i, N){
cin >> t[i];
}
cout << solve(N, T, t) << endl;
return 0;
}
| a.cc:21:10: fatal error: UnionFind.h: No such file or directory
21 | #include "UnionFind.h"
| ^~~~~~~~~~~~~
compilation terminated.
|
s557526989 | p03733 | C | #include <stdio.h>
int main(){
int i, N;
double sum, sa, T;
double t[1000000001];
scanf("%d %lf", &N, &T);
for(i = 1; i <= N; i++) {
scanf("%lf", &t[i]);
}
for(i = 1; i <= N; i++) {
sa = t[i + 1] - t[i];
if(sa => T) {
sum += T;
}
if(sa < T) {
sum += sa;
}
}
printf("%f", sum);
} | main.c: In function 'main':
main.c:16:24: error: expected expression before '>' token
16 | if(sa => T) {
| ^
|
s119504446 | p03733 | C | #include <stdio.h>
int main(){
int i, N;
double sum, sa, T;
double t[1000000001];
scanf("%d %lf", &N, &T);
for(i = 1; i <= N; i++) {
scanf("%lf", &t[i]);
}
for(i = 1; i <= N; i++) {
sa = t[i + 1] - t[i]
if(sa => T) {
sum += T;
}
if(sa < T) {
sum += sa;
}
}
printf("%f", sum);
} | main.c: In function 'main':
main.c:15:37: error: expected ';' before 'if'
15 | sa = t[i + 1] - t[i]
| ^
| ;
16 | if(sa => T) {
| ~~
|
s204582807 | p03733 | C | #include <stdio.h>
int main(){
double i, sum, sa, N, T;
double t[1000000001];
scanf("%lf %lf", &N, &T);
for(i = 1; i <= N; i++) {
scanf("%lf", &t[i]);
}
for(i = 1; i <= N; i++) {
sa = t[i + 1] - t[i]
if(sa => T) {
sum += T;
}
if(sa < T) {
sum += sa;
}
}
printf("%f", sum);
} | main.c: In function 'main':
main.c:10:32: error: array subscript is not an integer
10 | scanf("%lf", &t[i]);
| ^
main.c:14:23: error: array subscript is not an integer
14 | sa = t[i + 1] - t[i]
| ^
main.c:14:34: error: array subscript is not an integer
14 | sa = t[i + 1] - t[i]
| ^
main.c:14:37: error: expected ';' before 'if'
14 | sa = t[i + 1] - t[i]
| ^
| ;
15 | if(sa => T) {
| ~~
|
s824909357 | p03733 | C | #include <stdio.h>
int main(){
double i, sum, N, T;
double t[1000000001];
scanf("%lf %lf", &N, &T);
for(i = 1; i <= N; i++) {
scanf("%lf", &t[i]);
}
for(i = 1; i <= N; i++) {
if((t[i + 1] - t[i]) => T) {
sum += T;
}
if((t[i + 1] - t[i]) < T) {
sum += (t[i + 1] - t[i]);
}
}
printf("%f", sum);
} | main.c: In function 'main':
main.c:10:32: error: array subscript is not an integer
10 | scanf("%lf", &t[i]);
| ^
main.c:14:22: error: array subscript is not an integer
14 | if((t[i + 1] - t[i]) => T) {
| ^
main.c:14:33: error: array subscript is not an integer
14 | if((t[i + 1] - t[i]) => T) {
| ^
main.c:14:39: error: expected expression before '>' token
14 | if((t[i + 1] - t[i]) => T) {
| ^
main.c:17:22: error: array subscript is not an integer
17 | if((t[i + 1] - t[i]) < T) {
| ^
main.c:17:33: error: array subscript is not an integer
17 | if((t[i + 1] - t[i]) < T) {
| ^
main.c:18:34: error: array subscript is not an integer
18 | sum += (t[i + 1] - t[i]);
| ^
main.c:18:45: error: array subscript is not an integer
18 | sum += (t[i + 1] - t[i]);
| ^
|
s858035942 | p03733 | C++ | import java.util.*;
import java.io.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int T = sc.nextInt();
final int INF = 2000000000;
int[] start = new int[N+1];
int[] end = new int[N+1];
for(int i=0;i<N;i++){
start[i]=sc.nextInt();
end[i] = start[i]+T;
}
start[N]=INF;
end[N]=INF;//avoid AIOOBException
int s=0;
int e=0;
int time=0;
int water=0;
int ans=0;
while(e<N){
if(start[s]==end[e]){
if(water>0){
ans += (start[s]-time);
}
time = start[s];
s++;
e++;
}else if(start[s]>end[e]){//end
if(water>0){
ans += (end[e]-time);
}
water--;
time = end[e];
e++;
}else{//start[s]<end[e] //start
if(water>0){
ans += (start[s]-time);
}
water++;
time = start[s];
s++;
}
}
System.out.println(ans);
}
} | 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.io.*;
| ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: expected unqualified-id before 'public'
4 | public class Main {
| ^~~~~~
|
s814184585 | p03733 | C | #include <stdio.h>
int main(){
double i, sum, N, T;
double t[1000000001];
scanf("%lf %lf", N, T);
for(i = 1; i <= N; i++) {
scanf("%lf", t[i]);
}
for(i = 1; i <= N; i++) {
if((t[i + 1] - t[i]) => T) {
sum += T;
}
if((t[i + 1] - t[i]) < T) {
sum += (t[i + 1] - t[i]);
}
}
printf("%f", sum);
} | main.c: In function 'main':
main.c:10:31: error: array subscript is not an integer
10 | scanf("%lf", t[i]);
| ^
main.c:14:22: error: array subscript is not an integer
14 | if((t[i + 1] - t[i]) => T) {
| ^
main.c:14:33: error: array subscript is not an integer
14 | if((t[i + 1] - t[i]) => T) {
| ^
main.c:14:39: error: expected expression before '>' token
14 | if((t[i + 1] - t[i]) => T) {
| ^
main.c:17:22: error: array subscript is not an integer
17 | if((t[i + 1] - t[i]) < T) {
| ^
main.c:17:33: error: array subscript is not an integer
17 | if((t[i + 1] - t[i]) < T) {
| ^
main.c:18:34: error: array subscript is not an integer
18 | sum += (t[i + 1] - t[i]);
| ^
main.c:18:45: error: array subscript is not an integer
18 | sum += (t[i + 1] - t[i]);
| ^
|
s187526037 | p03733 | C++ | #include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;
int main(){
int N,
long long W,v,w;
scanf("%d %lld",&N,&W);
//制限の重さWまでのdpテーブルを用意して0埋めする
vector<int> dp(W+1);
fill(dp.begin(), dp.end(), 0);
//入力を受け取りながら受け取った荷物の重さのとこを確認
for(int i=0;i<N;i++){
scanf("%lld %lld",&v,&w);
dp[w]=max(dp[w],v);
//よくわからない
for(int j=0;j<W-w+1;j++){
if(dp[j]!=0){
dp[j+w]=max(dp[j+w],dp[j]+v);
}
}
}
//dpテーブルの最大値を出力
printf("%d\n",*max_element(dp.begin(),dp.end()));
return 0;
}
| a.cc: In function 'int main()':
a.cc:11:5: error: expected unqualified-id before 'long'
11 | long long W,v,w;
| ^~~~
a.cc:12:25: error: 'W' was not declared in this scope
12 | scanf("%d %lld",&N,&W);
| ^
a.cc:18:28: error: 'v' was not declared in this scope
18 | scanf("%lld %lld",&v,&w);
| ^
a.cc:18:31: error: 'w' was not declared in this scope
18 | scanf("%lld %lld",&v,&w);
| ^
|
s970765722 | p03733 | C++ | import java.util.*;
public class Main {
//-------------------------------------------------------------//
public static final void main(String[] args) { new Main().solve(); }
//-------------------------------------------------------------//
Scanner sc = new Scanner(System.in);
void solve() {
int N = sc.nextInt();
int T = sc.nextInt();
int[] t = new int[N];
for (int i = 0; i < N; i++) t[i] = sc.nextInt();
int ans = N * T;
for (int i = 0; i < N - 1; i++) {
int d = t[i + 1] - t[i];
if (d >= T) continue;
ans -= T - d;
}
System.out.println(ans);
}
}
| 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:3:1: error: expected unqualified-id before 'public'
3 | public class Main {
| ^~~~~~
|
s531437710 | p03733 | Java | import java.io.BufferedInputStream;
import java.util.Scanner;
public class C {
// 14:02-
public static void main(String[] args) {
Scanner sc = new Scanner(new BufferedInputStream(System.in));
int n = sc.nextInt();
int t = sc.nextInt();
long sum = 0L;
long until = 0L;
for (int i = 0; i < n; i++) {
int x = sc.nextInt();
sum -= Math.max(until - x, 0);
sum += t;
until = x + t;
}
System.out.println(sum);
}
}
| Main.java:4: error: class C is public, should be declared in a file named C.java
public class C {
^
1 error
|
s052853163 | p03733 | C++ | #include <bits/stdc++.h>
using namespace std;
#define times(n, i) uptil(0, n, i)
#define rtimes(n, i) downto((n) - 1, 0, i)
#define upto(f, t, i) for(int _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i) for(int _##i = (t), i = (f); i < _##i; i++)
#define downto(f, t, i) for(int _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(int _##i = (t), i = (f); i > _##i; i--)
typedef long double LD;
#define long long long
#if defined(EBUG) && !defined(ONLINE_JUDGE)
#define debug true
#define ln << endl
#else
#define debug false
#define ln << '\n'
#endif
#define tb << '\t'
#define sp << ' '
signed main() { // long: 64bit
if(!debug) {
cin.tie(0);
ios::sync_with_stdio(0);
}
int N, T;
scanf("%d%d",&N,&T);
long ans = N*T, before = -T;
times(N, i) {
int t;
scanf("%d",&t);
ans -= max(0, before + T - t);
before = t;
}
cout << ans ln;
return 0;
}
| a.cc: In function 'int main()':
a.cc:38:19: error: no matching function for call to 'max(int, long long int)'
38 | ans -= max(0, before + T - t);
| ~~~^~~~~~~~~~~~~~~~~~~
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:38:19: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
38 | ans -= max(0, before + T - 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:
/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:19: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
38 | ans -= max(0, before + T - t);
| ~~~^~~~~~~~~~~~~~~~~~~
|
s888539535 | p03734 | C++ | #include <bits/stdc++.h>
typedef long long ll;
//B
using namespace std;
inline ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b);}
inline ll lcm(ll a, ll b) { return a * b / gcd(a, b);}
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, w;
cin>>n>>w;
map<int,int> mp;
mp[0] = 0;
int weight, val;
for (int i =0; i<n; i++){
cin>>weight>>val;
for (auto it: mp){
if(it->first+ weight<=w){
if(mp.find(it->first + weight) == mp.end()){
mp[it->first+weight] = 0;
}
mp[it->first + weight] = max (mp[it->first+weight], mp[it->first]+val);
}
}
}
map<int,int> :: iterator it;
it = mp.end();
cout<<it.second<<"\n";
//cant do it based on weight, nor value
}
| a.cc: In function 'int main()':
a.cc:23:18: error: base operand of '->' has non-pointer type 'std::pair<const int, int>'
23 | if(it->first+ weight<=w){
| ^~
a.cc:24:30: error: base operand of '->' has non-pointer type 'std::pair<const int, int>'
24 | if(mp.find(it->first + weight) == mp.end()){
| ^~
a.cc:25:26: error: base operand of '->' has non-pointer type 'std::pair<const int, int>'
25 | mp[it->first+weight] = 0;
| ^~
a.cc:27:22: error: base operand of '->' has non-pointer type 'std::pair<const int, int>'
27 | mp[it->first + weight] = max (mp[it->first+weight], mp[it->first]+val);
| ^~
a.cc:27:52: error: base operand of '->' has non-pointer type 'std::pair<const int, int>'
27 | mp[it->first + weight] = max (mp[it->first+weight], mp[it->first]+val);
| ^~
a.cc:27:74: error: base operand of '->' has non-pointer type 'std::pair<const int, int>'
27 | mp[it->first + weight] = max (mp[it->first+weight], mp[it->first]+val);
| ^~
a.cc:33:14: error: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} has no member named 'second'
33 | cout<<it.second<<"\n";
| ^~~~~~
|
s707032495 | p03734 | C++ | #include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
ll V;
vector<vector<edge> > G;
vector<ll> d;
graph(ll n){
init(n);
}
void init(ll n){
V = n;
G.resize(V);
d.resize(V);
rep(i,V){
d[i] = INF;
}
}
void add_edge(ll s, ll t, ll cost){
edge e;
e.to = t, e.cost = cost;
G[s].push_back(e);
}
void dijkstra(ll s){
rep(i,V){
d[i] = INF;
}
d[s] = 0;
priority_queue<P,vector<P>, greater<P> > que;
que.push(P(0,s));
while(!que.empty()){
P p = que.top(); que.pop();
ll v = p.second;
if(d[v]<p.first) continue;
for(auto e : G[v]){
if(d[e.to]>d[v]+e.cost){
d[e.to] = d[v]+e.cost;
que.push(P(d[e.to],e.to));
}
}
}
}
};
class UnionFind
{
public:
int par[100005];
int depth[100005];
int nGroup[100005];
UnionFind(int n) {
init(n);
}
void init(int n) {
for(int i=0; i<n; i++) {
par[i] = i;
depth[i] = 0;
nGroup[i] = 1;
}
}
int root(int x) {
if(par[x] == x) {
return x;
} else {
return par[x] = root(par[x]);
}
}
bool same(int x, int y) {
return root(x) == root(y);
}
void unite(int x, int y) {
x = root(x);
y = root(y);
if(x == y) return;
if(depth[x] < depth[y]) {
par[x] = y;
nGroup[y] += nGroup[x];
nGroup[x] = 0;
} else {
par[y] = x;
nGroup[x] += nGroup[y];
nGroup[y] = 0;
if(depth[x] == depth[y])
depth[x]++;
}
}
};
const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++){
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
ll COM(ll n, ll k){
if (n < k) return 0;
if (n < 0 || k < 0) return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
ll n,w; cin>>n>>w;
vl w0(105,0),w1(105,0),w2(105,0),w3(105,0);
ll a,b;cin>>a>>b;
w0.pb(b);
rep(i,n-1){
ll r,l;
cin>>r>>l;
if(r==a)w0.pb(l);
if(r==a+1)w1.pb(l);
if(r==a+2)w2.pb(l);
if(r==a+3)w3.pb(l);
}
ll l0=w0.size(),l1=w1.size(),l2=w2.size(),l3=w3.size();
ll ans = 0, ww = 0 , ca = 0;
sort(all(w0));
sort(all(w1));
sort(all(w2));
sort(all(w3));
reverse(all(w0));
reverse(all(w1));
reverse(all(w2));
reverse(all(w3));
for(ll i=1; i<=l0; i++){
for(ll k=1; k<=l1; k++){
for(ll j=1; j<=l2; j++){
for(ll m=1; m<=l3; m++){
ca = 0, ww = 0;
rep(o,i){
ca+=w0[i-1];}
ww+=r*i;
rep(o,k){
ca+=w1[k-1];}
ww+=(r+1)*k;
rep(o,j){
ca+=w2[j-1];}
ww+=(r+2)*j;
rep(o,m){
ca+=w3[m-1];}
ww+=(r+3)*m;
if(ww<=w){
ans = max(ans,ca);}
}}}}
cout << ans << endl;}
| a.cc: In function 'int main()':
a.cc:177:5: error: 'r' was not declared in this scope
177 | ww+=r*i;
| ^
|
s252546681 | p03734 | C++ | #include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
using Graph = vector<vector<int>>;
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
ll V;
vector<vector<edge> > G;
vector<ll> d;
graph(ll n){
init(n);
}
void init(ll n){
V = n;
G.resize(V);
d.resize(V);
rep(i,V){
d[i] = INF;
}
}
void add_edge(ll s, ll t, ll cost){
edge e;
e.to = t, e.cost = cost;
G[s].push_back(e);
}
void dijkstra(ll s){
rep(i,V){
d[i] = INF;
}
d[s] = 0;
priority_queue<P,vector<P>, greater<P> > que;
que.push(P(0,s));
while(!que.empty()){
P p = que.top(); que.pop();
ll v = p.second;
if(d[v]<p.first) continue;
for(auto e : G[v]){
if(d[e.to]>d[v]+e.cost){
d[e.to] = d[v]+e.cost;
que.push(P(d[e.to],e.to));
}
}
}
}
};
class UnionFind
{
public:
int par[100005];
int depth[100005];
int nGroup[100005];
UnionFind(int n) {
init(n);
}
void init(int n) {
for(int i=0; i<n; i++) {
par[i] = i;
depth[i] = 0;
nGroup[i] = 1;
}
}
int root(int x) {
if(par[x] == x) {
return x;
} else {
return par[x] = root(par[x]);
}
}
bool same(int x, int y) {
return root(x) == root(y);
}
void unite(int x, int y) {
x = root(x);
y = root(y);
if(x == y) return;
if(depth[x] < depth[y]) {
par[x] = y;
nGroup[y] += nGroup[x];
nGroup[x] = 0;
} else {
par[y] = x;
nGroup[x] += nGroup[y];
nGroup[y] = 0;
if(depth[x] == depth[y])
depth[x]++;
}
}
};
const ll MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++){
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
// 二項係数計算
ll COM(ll n, ll k){
if (n < k) return 0;
if (n < 0 || k < 0) return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main() {
ll n,w; cin>>n>>w;
vl w0[105]={},w1[105]={},w2[105]={},w3[105]={};
ll a,b;cin>>a>>b;
w0.pb(b);
rep(i,n-1){
ll r,l;
cin>>r>>l;
if(r==a)w0.pb(l);
if(r==a+1)w1.pb(l);
if(r==a+2)w2.pb(l);
if(r==a+3)w3.pb(l);
}
ll l0=w0.size(),l1=w1.size(),l2=w2.size(),l3=w3.size();
ll ans = 0, ww = 0 , ca = 0;
sort(all(w0));
sort(all(w1));
sort(all(w2));
sort(all(w3));
reverse(all(w0));
reverse(all(w1));
reverse(all(w2));
reverse(all(w3));
for(ll i=1; i<=l0; i++){
for(ll k=1; k<=l1; k++){
for(ll j=1; j<=l2; j++){
for(ll m=1; m<=l3; m++){
ca = 0, ww = 0;
rep(o,i){
ca+=w0[i-1];}
ww+=r*i;
rep(o,k){
ca+=w1[k-1];}
ww+=(r+1)*k;
rep(o,j){
ca+=w2[j-1];}
ww+=(r+2)*j;
rep(o,m){
ca+=w3[m-1];}
ww+=(r+3)*m;
if(ww<=w){
ans = max(ans,ca);}
}}}}
cout << ans << endl;} | a.cc: In function 'int main()':
a.cc:9:12: error: request for member 'push_back' in 'w0', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
9 | #define pb push_back
| ^~~~~~~~~
a.cc:151:4: note: in expansion of macro 'pb'
151 | w0.pb(b);
| ^~
a.cc:9:12: error: request for member 'push_back' in 'w0', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
9 | #define pb push_back
| ^~~~~~~~~
a.cc:155:12: note: in expansion of macro 'pb'
155 | if(r==a)w0.pb(l);
| ^~
a.cc:9:12: error: request for member 'push_back' in 'w1', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
9 | #define pb push_back
| ^~~~~~~~~
a.cc:156:14: note: in expansion of macro 'pb'
156 | if(r==a+1)w1.pb(l);
| ^~
a.cc:9:12: error: request for member 'push_back' in 'w2', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
9 | #define pb push_back
| ^~~~~~~~~
a.cc:157:14: note: in expansion of macro 'pb'
157 | if(r==a+2)w2.pb(l);
| ^~
a.cc:9:12: error: request for member 'push_back' in 'w3', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
9 | #define pb push_back
| ^~~~~~~~~
a.cc:158:14: note: in expansion of macro 'pb'
158 | if(r==a+3)w3.pb(l);
| ^~
a.cc:160:10: error: request for member 'size' in 'w0', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
160 | ll l0=w0.size(),l1=w1.size(),l2=w2.size(),l3=w3.size();
| ^~~~
a.cc:11:20: error: request for member 'begin' in 'w0', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
11 | #define all(x) (x).begin(),(x).end()
| ^~~~~
a.cc:162:6: note: in expansion of macro 'all'
162 | sort(all(w0));
| ^~~
a.cc:11:32: error: request for member 'end' in 'w0', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
11 | #define all(x) (x).begin(),(x).end()
| ^~~
a.cc:162:6: note: in expansion of macro 'all'
162 | sort(all(w0));
| ^~~
a.cc:11:20: error: request for member 'begin' in 'w1', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
11 | #define all(x) (x).begin(),(x).end()
| ^~~~~
a.cc:163:6: note: in expansion of macro 'all'
163 | sort(all(w1));
| ^~~
a.cc:11:32: error: request for member 'end' in 'w1', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
11 | #define all(x) (x).begin(),(x).end()
| ^~~
a.cc:163:6: note: in expansion of macro 'all'
163 | sort(all(w1));
| ^~~
a.cc:11:20: error: request for member 'begin' in 'w2', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
11 | #define all(x) (x).begin(),(x).end()
| ^~~~~
a.cc:164:6: note: in expansion of macro 'all'
164 | sort(all(w2));
| ^~~
a.cc:11:32: error: request for member 'end' in 'w2', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
11 | #define all(x) (x).begin(),(x).end()
| ^~~
a.cc:164:6: note: in expansion of macro 'all'
164 | sort(all(w2));
| ^~~
a.cc:11:20: error: request for member 'begin' in 'w3', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
11 | #define all(x) (x).begin(),(x).end()
| ^~~~~
a.cc:165:6: note: in expansion of macro 'all'
165 | sort(all(w3));
| ^~~
a.cc:11:32: error: request for member 'end' in 'w3', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
11 | #define all(x) (x).begin(),(x).end()
| ^~~
a.cc:165:6: note: in expansion of macro 'all'
165 | sort(all(w3));
| ^~~
a.cc:11:20: error: request for member 'begin' in 'w0', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
11 | #define all(x) (x).begin(),(x).end()
| ^~~~~
a.cc:166:9: note: in expansion of macro 'all'
166 | reverse(all(w0));
| ^~~
a.cc:11:32: error: request for member 'end' in 'w0', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
11 | #define all(x) (x).begin(),(x).end()
| ^~~
a.cc:166:9: note: in expansion of macro 'all'
166 | reverse(all(w0));
| ^~~
a.cc:11:20: error: request for member 'begin' in 'w1', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
11 | #define all(x) (x).begin(),(x).end()
| ^~~~~
a.cc:167:9: note: in expansion of macro 'all'
167 | reverse(all(w1));
| ^~~
a.cc:11:32: error: request for member 'end' in 'w1', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
11 | #define all(x) (x).begin(),(x).end()
| ^~~
a.cc:167:9: note: in expansion of macro 'all'
167 | reverse(all(w1));
| ^~~
a.cc:11:20: error: request for member 'begin' in 'w2', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
11 | #define all(x) (x).begin(),(x).end()
| ^~~~~
a.cc:168:9: note: in expansion of macro 'all'
168 | reverse(all(w2));
| ^~~
a.cc:11:32: error: request for member 'end' in 'w2', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
11 | #define all(x) (x).begin(),(x).end()
| ^~~
a.cc:168:9: note: in expansion of macro 'all'
168 | reverse(all(w2));
| ^~~
a.cc:11:20: error: request for member 'begin' in 'w3', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
11 | #define all(x) (x).begin(),(x).end()
| ^~~~~
a.cc:169:9: note: in expansion of macro 'all'
169 | reverse(all(w3));
| ^~~
a.cc:11:32: error: request for member 'end' in 'w3', which is of non-class type 'vl [105]' {aka 'std::vector<long long int> [105]'}
11 | #define all(x) (x).begin(),(x).end()
| ^~~
a.cc:169:9: note: in expansion of macro 'all'
169 | reverse(all(w3));
| ^~~
a.cc:171:16: error: 'l1' was not declared in this scope; did you mean 'l0'?
171 | for(ll k=1; k<=l1; k++){
| ^~
| l0
a.cc:172:16: error: 'l2' was not declared in this scope; did you mean 'l0'?
172 | for(ll j=1; j<=l2; j++){
| ^~
| l0
a.cc:173:16: error: 'l3' was not declared in this scope; did you mean 'l0'?
173 | for(ll m=1; m<=l3; m++){
| ^~
| l0
a.cc:176:3: error: no match for 'operator+=' (operand types are 'll' {aka 'long long int'} and 'vl' {aka 'std::vector<long long int>'})
176 | ca+=w0[i-1];}
| ~~^~~~~~~~~
a.cc:177:5: error: 'r' was not declared in this scope
177 | ww+=r*i;
| ^
a.cc:179:3: error: no match for 'operator+=' (operand types are 'll' {aka 'long long int'} and 'vl' {aka 'std::vector<long long int>'})
179 | ca+=w1[k-1];}
| ~~^~~~~~~~~
a.cc:182:3: error: no match for 'operator+=' (operand types are 'll' {aka 'long long int'} and 'vl' {aka 'std::vector<long long int>'})
182 | ca+=w2[j-1];}
| ~~^~~~~~~~~
a.cc:185:3: error: no match for 'operator+=' (operand types are 'll' {aka 'long long int'} and 'vl' {aka 'std::vector<long long int>'})
185 | ca+=w3[m-1];}
| ~~^~~~~~~~~
|
s962888187 | p03734 | C++ | #include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
ll dp[101][305];
int main() {
int n,w;
scanf("%d%d",&n,&w);
int ws = 0, sum = 0;
rep(i,n) {
int a,b;
scanf("%d%d",&a,&b);
if (!i) {
ws = a;
}
// 壓縮
a -= ws;
// 選擇j個,重量為sum時,選或不選第i個物品
for ( int j=i; j>=0; j-- ) {
for ( int k=sum; k>=0; k-- ) {
chmax(dp[j+1][k+a], dp[j][k]+b);
}
}
sum += a;
}
ll ans = 0;
// 選擇i個,壓縮後的重量j
for ( int i=0; i<=n; i++ ) {
for ( int j=0; j<=sum; j++ ) {
ll x = (ll)ws*i+j;
if (x <= w) {
maxs(ans,dp[i][j]);
}
}
}
cout<<ans<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:85:9: error: 'chmax' was not declared in this scope
85 | chmax(dp[j+1][k+a], dp[j][k]+b);
| ^~~~~
|
s873709626 | p03734 | C++ | #include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
ll dp[101][305];
int main() {
int n,w;
scanf("%d%d",&n,&w);
int ws = 0, sum = 0;
rep(i,n) {
int a,b;
scanf("%d%d",&a,&b);
if (!i) {
ws = a;
}
// 壓縮
a -= ws;
// 選擇j個,重量為sum時,選或不選第i個物品
for ( int j=i; j>=0; j-- ) {
for ( int k=sum; k>=0; k-- ) {
chmax(dp[j+1][k+a], dp[j][k]+b);
}
}
sum += a;
}
ll ans = 0;
// 選擇i個,壓縮後的重量j
for ( int i=0; i<=n; i++ ) {
for ( int j=0; j<=swm; j++ ) {
ll x = (ll)ws*i+j;
if (x <= w) {
maxs(ans,dp[i][j]);
}
}
}
cout<<ans<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:85:9: error: 'chmax' was not declared in this scope
85 | chmax(dp[j+1][k+a], dp[j][k]+b);
| ^~~~~
a.cc:93:23: error: 'swm' was not declared in this scope; did you mean 'sum'?
93 | for ( int j=0; j<=swm; j++ ) {
| ^~~
| sum
|
s196251216 | p03734 | C++ | #include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) {
return '"' + s + '"';
}
string to_string(const char* s) {
return to_string((string) s);
}
string to_string(bool b) {
return (b ? "true" : "false");
}
string to_string(vector<bool> v) {
bool first = true;
string res = "{";
for (int i = 0; i < static_cast<int>(v.size()); i++) {
if (!first) {
res += ", ";
}
first = false;
res += to_string(v[i]);
}
res += "}";
return res;
}
template <size_t N>
string to_string(bitset<N> v) {
string res = "";
for (size_t i = 0; i < N; i++) {
res += static_cast<char>('0' + v[i]);
}
return res;
}
template <typename A>
string to_string(A v) {
bool first = true;
string res = "{";
for (const auto &x : v) {
if (!first) {
res += ", ";
}
first = false;
res += to_string(x);
}
res += "}";
return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
cerr << " " << to_string(H);
debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep(i,n) for (int i = 0; i < n; ++i)
#define reps(i,s,n) for (int i = s; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
#define per(i,n) for (int i = n - 1; i >= 0; --i)
#define per1(i,n) for (int i = n; i >= 1; --i)
#define all(c) begin(c),end(c)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline T intceil(T a, T b) { return (a + (b - 1)) / b; }
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const long long MOD = 1e9+7;
#define precout() cout << std::fixed << std::setprecision(20);
#define print(a) cout << a << endl;
const string alphabet = "abcdefghijklmnopqrstuvwxyz";
const int dy[4] = { 0, 1, 0, -1 };
const int dx[4] = { 1, 0, -1, 0 };
// if(nextH >= 0 && nextH < H && nextW >= 0 && nextW < W)
static const long double pi = acos(-1.0);
typedef complex<ld> cd;
#define int long long
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
int N,MAXW; cin >> N >> MAXW;
vector<int> W(N), V(N);
int base = 1e9 * 2;
rep(i, N) {
cin >> W[i] >> V[i];
chmin(base, W[i]);
}
rep(i, N) {
W[i] -= base;
}
vector<vector<vector<int>>> dp(N + 1, vector<vector<int>>(N + 1, vector<int>(301, 0)));
rep1(i, N) { // 0~i番目の荷物
rep(j, N + 1) { // j個使って
rep(k, 301) { // 重さwの最大価値
if(j && k - W[i - 1] >= 0) {
dp[i][j][k] = max(dp[i - 1][j][k], dp[i - 1][j - 1][k - W[i - 1]] + V[i - 1]);
} else {
dp[i][j][k] = dp[i - 1][j][k];
}
}
}
}
int ans = 0;
for(int i = 0; i <= N; i++){
for(int j = 0; j <= 300; j++){
if(j + base * i <= MAXW){
ans = max(ans, dp[N][i][j]);
}
}
}
cout << ans << endl;
return 0;
}
| cc1plus: error: '::main' must return 'int'
|
s487148268 | p03734 | C++ | #include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MAX 510000
#define rrep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define dcout cout<<fixed<<setprecision(15);
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
constexpr int MOD = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template< typename S, typename T >
inline void chmax(S &a, const T &b) { if(a < b) a = b; }
template< typename S, typename T >
inline void chmin(S &a, const T &b) { if(a > b) a = b; }
//lcm//
ll gcd(ll x, ll y) {
if (x == 0) return y;
return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }
//a^n mod p//
ll modpow(ll a, ll n, ll p) {
if(n==0) return (ll)1;
if (n == 1) return a % p;
if (n % 2 == 1) return (a * modpow(a, n - 1, p)) % p;
ll t = modpow(a, n / 2, p);
return (t * t) % p;
}
//inversemod//
ll modinv(ll a, ll m) {
if(m==0)return (ll)1;
ll b = m, u = 1, v = 0;
while (b) {
ll t = a / b;
a -= t * b; swap(a, b);
u -= t * v; swap(u, v);
}
u %= m;
if (u < 0) u += m;
return u;
}
//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];
//
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
//
ll COM(ll n, ll k) {
if (n < k) return 0;
if (n < 0 || k < 0) return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
//LARGE n
ll com(ll n,ll m){
if(n<m || n<=0 ||m<0){
return 0;
}
if( m==0 || n==m){
return 1;
}
ll k=1;
for(ll i=1;i<=m;i++){
k*=(n-i+1);
k%=MOD;
k*=modinv(i,MOD);
k%=MOD;
}
return k;
}
//radP
ll rad(ll u, ll p){
ll cnt=0;
while(u%p==0){
u/=p;
cnt++;
}
return cnt;
}
////////////////////////////////////////////////////////////////////
int main() {
ll n;
cin>>n;
ll w;
cin>>w;
vector<P> wv{};
rep(i,n){
ll p,q;
cin>>p>>q;
wv.pb(mp(p,q));
}
sort(ALL(wv));
ll ans=0;
vector<ll> vec{};
map<ll,ll> MP{};
MP[0]=(ll)0;
vec.push_back((ll)0);
for(ll i=0;i<wv.size();i++){
ll mx=vec.size();
for(ll j=0;j<mx;j++){
ll z=vec[j];
if(z+wv[i].first>w)continue;
if(!MP.count(z+wv[i].first)){
MP[z+wv[i].first]=MP[z]+wv[i].second;
ans=max(ans,MP[z+wv[i].first]);
vec.pb(z+wv[i].first);
}
else {MP[z+wv[i].first]=max(MP[z+wv[i].first], MP[z]+wv[i].second);
ans=max(ans,MP[z+wv[i].first]);
}
}
}
}
cout<<ans<<endl;
}
| a.cc:149:1: error: 'cout' does not name a type; did you mean 'dcout'?
149 | cout<<ans<<endl;
| ^~~~
| dcout
a.cc:150:1: error: expected declaration before '}' token
150 | }
| ^
|
s147183341 | p03734 | C++ | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;
#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
template<class T>
bool chmin(T &a, T b)
{
if (a > b)
{
a = b;
return false;
}
return true;
}
template<class T>
bool chmax(T &a, T b)
{
if (a < b)
{
a = b;
return false;
}
return true;
}
template<class T>
bool chmax(T &a, initializer_list<T> l)
{
return chmax(a, *max_element(l.begin(), l.end()));
}
template<class T>
bool chmin(T &a, initializer_list<T> l)
{
return chmin(a, *min_element(l.begin(), l.end));
}
ll N, W;
ll w0{-1};
map<ll, vector<ll>> m;
ll solve(ll i, ll w, ll v, vector<ll>& vec)
{
if (i == 4)
{
if (w <= W) return v;
else return 0;
}
ll res{0};
for (ll k = 0; k <= vec[i].size(); ++k)
{
ll ww = (w0+i);
ll tmp = solve(i+1, w+ww*k,
v+accumulate(m[ww].begin(),
m[ww].begin()+k, 0ll), vec);
chmax(res, tmp);
}
return res;
}
int main(int argc, char **argv)
{
cin >> N >> W;
REP(i, N)
{
ll w, v; cin >> w >> v;
m[w].push_back(v);
if (w0 == -1)
w0 = w;
}
vector<ll> cntv(4, 0);
ll i{0};
for (auto &p : m)
{
sort(ALL(p.second), greater<ll>());
cntv[i++] = (p.second.size()+1);
}
std::cout << solve(0, 0, 0, cntv) << std::endl;
}
| a.cc: In function 'll solve(ll, ll, ll, std::vector<long long int>&)':
a.cc:62:36: error: request for member 'size' in '(& vec)->std::vector<long long int>::operator[](((std::vector<long long int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'}
62 | for (ll k = 0; k <= vec[i].size(); ++k)
| ^~~~
|
s936686987 | p03734 | C++ | #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
int n;
ll w[n],v[n];
ll W;
pair<ll,ll> ps[1<<n/2];
int n2=n/2;
for(int i=0;i<1<<n2;i++){
ll sw=0,sv=0;
rep(j,n2){
if(i>>j&1){
sw+=w[j];
sv+=v[j];
}
}
ps[i]={sw,sv};
}
sort(ps,ps+(1<<n2));
int m=1;
for(int i=1;i<1<<n2;i++){
if(ps[m-1].second<ps[i].second){
ps[m++]=ps[i];
}
}
ll res=0;
for(int i=0;i<1<<(n-n2);i++){
ll sw=0;sv=0;
for(int j=0;j<n-n2;j++){
if(i>>j&1){
sw+=w[n2+j];
sv+=v[n2+j];
}
}
if(sw<=W){
ll tv=(lower_bound(ps,ps+m,make_pair(W-sw,INF))-1)->second;
res=max(res,sv+tv);
}
}
cout<<res<<endl;
} | a.cc: In function 'int main()':
a.cc:34:17: error: 'sv' was not declared in this scope; did you mean 'sw'?
34 | ll sw=0;sv=0;
| ^~
| sw
a.cc:42:55: error: 'INF' was not declared in this scope
42 | ll tv=(lower_bound(ps,ps+m,make_pair(W-sw,INF))-1)->second;
| ^~~
|
s929270986 | p03734 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n,W;cin>>n>>W;
vector<int> dp(w),a[4];
rep(i,n){
int w,v,w1;cin>>w>>v;
if(i==0)w1=w;
a[w-w1].push_back(v);
}
rep(i,4){
sort(a[i].begin(),a[i].end());
a[i].push_back(0);
reverse(a[i].begin(),a[i].end());
for(int j=1;j<a[i].size();j++)a[i][j]+=a[i][j-1];
}
ll ans=0;
for(int i=0;i<a[0].size();i++){
for(int j=0;j<a[1].size();j++){
for(int k=0;k<a[2].size();k++){
for(int l=0;l<a[3].size();l++){
int fact=i*w1+j*(w1+1)+k*(w1+2)+l*(w1+3);
if(fact<=W)ans=max(ans,a[0][i]+a[1][j]+a[2][k]+a[3][l]);
}
}
}
}
cout<<ans<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:11:18: error: 'w' was not declared in this scope
11 | vector<int> dp(w),a[4];
| ^
a.cc:28:22: error: 'w1' was not declared in this scope; did you mean 'y1'?
28 | int fact=i*w1+j*(w1+1)+k*(w1+2)+l*(w1+3);
| ^~
| y1
a.cc:29:29: error: no matching function for call to 'max(ll&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
29 | if(fact<=W)ans=max(ans,a[0][i]+a[1][j]+a[2][k]+a[3][l]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:29: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
29 | if(fact<=W)ans=max(ans,a[0][i]+a[1][j]+a[2][k]+a[3][l]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:29: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
29 | if(fact<=W)ans=max(ans,a[0][i]+a[1][j]+a[2][k]+a[3][l]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s690624287 | p03734 | C++ | #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const ll INF=1e18;
int main(){
cin.tie(0);ios::sync_with_stdio(false);
ll n,W;
cin>>n>>W;
V<ll> w(n),v(n);
rep(i,n) cin>>w[i]>>v[i];
ll ans=0;
V<V<ll>> c(4);
rep(i,n) c[w[i]-w[0]].push_back(v[i]);
ll s[5][101];
rep(i,4) sort(all(c[i]),greater<ll>());
rep(i,4){
rep(j,c[i].size()+1) s[i][j]=0;
}
rep(i,4){
rep(j,c[i].size()) s[i][j+1]=s[i][j]+c[i][j];
}
for(ll i=0;i<=n;i++){
for(ll j=0;j<=n;j++){
for(ll k=0;k<=n;k++){
if(i*w[0]+j*(w[0]+1)+k*(w[0]+2)>W) continue;
ll l=min((W-(i*w[0]+j*(w[0]+1)+k*(w[0]+2)))/(w[0]+3),(LLONG_MAX)c[3].size());
if(i>c[0].size()||j>c[1].size()||k>c[2].size()) continue;
chmax(ans,s[0][i]+s[1][j]+s[2][k]+s[3][l]);
}
}
}
cout<<ans<<endl;
}
//ペナルティ出しても焦らない ACできると信じろ!!!
//どうしてもわからないときはサンプルで実験 何か見えてくるかも
//頭で考えてダメなら紙におこせ!!
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ!
(適切にmodをとれ にぶたんで途中で切り上げろ)
制約をよく読め!
(全探索できるなら全探索しろ)
stringの計算量(扱い)注意
コーナー注意!(特に数値が小さいものについては要検証)
N行出力のときは'\n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え(=でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ!
*/ | a.cc: In function 'int main()':
a.cc:48:81: error: expected ')' before 'c'
48 | ll l=min((W-(i*w[0]+j*(w[0]+1)+k*(w[0]+2)))/(w[0]+3),(LLONG_MAX)c[3].size());
| ~ ^
| )
|
s331048186 | p03734 | C++ | #include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl
class mint {
long long x;
public:
mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
mint operator-() const {
return mint(-x);
}
mint& operator+=(const mint& a) {
if ((x += a.x) >= MOD) x -= MOD;
return *this;
}
mint& operator-=(const mint& a) {
if ((x += MOD-a.x) >= MOD) x -= MOD;
return *this;
}
mint& operator*=(const mint& a) {
(x *= a.x) %= MOD;
return *this;
}
mint operator+(const mint& a) const {
mint res(*this);
return res+=a;
}
mint operator-(const mint& a) const {
mint res(*this);
return res-=a;
}
mint operator*(const mint& a) const {
mint res(*this);
return res*=a;
}
mint pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
// for prime MOD
mint inv() const {
return pow(MOD-2);
}
mint& operator/=(const mint& a) {
return (*this) *= a.inv();
}
mint operator/(const mint& a) const {
mint res(*this);
return res/=a;
}
friend ostream& operator<<(ostream& os, const mint& m){
os << m.x;
return os;
}
};
/* -- template -- */
const int MAX_N = 101, MAX_W = 3001;
int dp[MAX_N][MAX_N][MAX_W]; //dp[i + 1][j][w] : i番目までみたとき,j個で重さw以下での価値の最大値
int main() {
int N, W; cin >> N >> W;
int w[N], v[N];
rep(i, N) cin >> w[i] >> v[i];
rep(i, N - 1) w[i + 1] -= (w[0] - 1);
int tmp = w[0];
w[0] = 1;
rep(i, N) {
rep(j, N){
rep(ww, MAX_W) {
dp[i + 1][j + 1][ww] = max(dp[i][j + 1][ww], dp[i + 1][j + 1][ww])
if(ww - w[i] >= 0)
dp[i + 1][j + 1][ww] = max(dp[i + 1][j + 1][ww], dp[i][j][ww - w[i]] + v[i]);
}
}
}
int ans = 0;
rep(j, N) {
rep(ww, MAX_W) {
if((j + 1) * (tmp - 1) + ww == W)
ans = max(ans, dp[N][j + 1][ww]);
}
}
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:90:83: error: expected ';' before 'if'
90 | dp[i + 1][j + 1][ww] = max(dp[i][j + 1][ww], dp[i + 1][j + 1][ww])
| ^
| ;
91 | if(ww - w[i] >= 0)
| ~~
|
s656605857 | p03734 | Java |
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int W = sc.nextInt();
int[] w = new int[n];
int[] v = new int[n];
ArrayList<Integer> arr0 = new ArrayList<Integer>();
ArrayList<Integer> arr1 = new ArrayList<Integer>();
ArrayList<Integer> arr2 = new ArrayList<Integer>();
ArrayList<Integer> arr3 = new ArrayList<Integer>();
arr0.add(0);
arr1.add(0);
arr2.add(0);
arr3.add(0);
for (int i = 0; i < n; i++) {
w[i] = Integer.parseInt(sc.next());
v[i] = Integer.parseInt(sc.next());
if (w[i] - w[0] == 0)
arr0.add(v[i]);
if (w[i] - w[0] == 1)
arr1.add(v[i]);
if (w[i] - w[0] == 2)
arr2.add(v[i]);
if (w[i] - w[0] == 3)
arr3.add(v[i]);
}
Collections.sort(arr0, Collections.reverseOrder());
Collections.sort(arr1, Collections.reverseOrder());
Collections.sort(arr2, Collections.reverseOrder());
Collections.sort(arr3, Collections.reverseOrder());
ArrayList<Long> arrsum0 = new ArrayList<Long>();
ArrayList<Long> arrsum1 = new ArrayList<Long>();
ArrayList<Long> arrsum2 = new ArrayList<Long>();
ArrayList<Long> arrsum3 = new ArrayList<Long>();
arrsum0.add(0l);
arrsum1.add(0l);
arrsum2.add(0l);
arrsum3.add(0l);
long sum = 0;
for (int i = 0; i < arr0.size(); i++) {
sum += arr0.get(i);
arrsum0.add(sum);
}
sum = 0;
for (int i = 0; i < arr1.size(); i++) {
sum += arr1.get(i);
arrsum1.add(sum);
}
sum = 0;
for (int i = 0; i < arr2.size(); i++) {
sum += arr2.get(i);
arrsum2.add(sum);
}
sum = 0;
for (int i = 0; i < arr3.size(); i++) {
sum += arr3.get(i);
arrsum3.add(sum);
}
long max = 0;
for (int i = 0; i < arr0.size(); i++) {
for (int j = 0; j < arr1.size(); j++) {
for (int k = 0; k < arr2.size(); k++) {
for (int m = 0; m < arr3.size(); m++) {
if (i * w[0] + j * (w[0] + 1) + k * (w[0] + 2) + m * (w[0] + 3) > W)
continue;
max = Math.max(max, arrsum0.get(i) + arrsum1.get(j) + arrsum2.get(k) + arrsum3.get(m));
}
}
}
}
System.out.println(max);
}
}
| Main.java:7: error: illegal character: '\u3000'
public class?Main {
^
1 error
|
s560630816 | p03734 | C++ | a | a.cc:1:1: error: 'a' does not name a type
1 | a
| ^
|
s253480513 | p03734 | C++ | #include<bits/stdc++.h>
using namespace std;
const int MAX_N = 100;
const int MAX_W = INF;
int n, W;
int w[MAX_N], v[MAX_N];
int dp[MAX_N + 1][MAX_W + 1];
int rec_dp(int i, int j) {
if (dp[i][j] != -1) {
return dp[i][j];
}
int res;
if (i == n) {
res = 0;
} else if (j < w[i]) {
res = rec_dp(i + 1, j);
} else {
res = max(
rec_dp(i + 1, j),
rec_dp(i + 1, j - w[i]) + v[i]
);
}
return dp[i][j] = res;
}
void solve_dp() {
memset(dp, -1, sizeof(dp));
cout << rec_dp(0, W) << endl;
}
int main() {
cin >> n >> W;
for (int i = 0; i < n; i++) {
cin >> w[i] >> v[i];
}
solve_dp();
return 0;
} | a.cc:5:19: error: 'INF' was not declared in this scope
5 | const int MAX_W = INF;
| ^~~
a.cc:10:25: error: size of array 'dp' is not an integral constant-expression
10 | int dp[MAX_N + 1][MAX_W + 1];
| ~~~~~~^~~
|
s331212278 | p03734 | C++ | #include<bits/stdc++.h>
using namespace std;
const int MAX_N = 100;
const int MAX_W = INF;
int n, W;
int w[MAX_N], v[MAX_N];
int dp[MAX_N + 1][MAX_W + 1];
int rec_dp(int i, int j) {
if (dp[i][j] != -1) {
return dp[i][j];
}
int res;
if (i == n) {
res = 0;
} else if (j < w[i]) {
res = rec_dp(i + 1, j);
} else {
res = max(
rec_dp(i + 1, j),
rec_dp(i + 1, j - w[i]) + v[i]
);
}
結果をテーブルに記憶する
return dp[i][j] = res;
}
メモ化再帰を用いた解法
void solve_dp() {
memset(dp, -1, sizeof(dp));
cout << rec_dp(0, W) << endl;
}
int main() {
cin >> n >> W;
for (int i = 0; i < n; i++) {
cin >> w[i] >> v[i];
}
solve_dp();
return 0;
} | a.cc:5:19: error: 'INF' was not declared in this scope
5 | const int MAX_W = INF;
| ^~~
a.cc:10:25: error: size of array 'dp' is not an integral constant-expression
10 | int dp[MAX_N + 1][MAX_W + 1];
| ~~~~~~^~~
a.cc: In function 'int rec_dp(int, int)':
a.cc:32:4: error: '\U00007d50\U0000679c\U00003092\U000030c6\U000030fc\U000030d6\U000030eb\U0000306b\U00008a18\U000061b6\U00003059\U0000308b' was not declared in this scope
32 | 結果をテーブルに記憶する
| ^~~~~~~~~~~~~~~~~~~~~~~~
a.cc: At global scope:
a.cc:35:2: error: '\U000030e1\U000030e2\U00005316\U0000518d\U00005e30\U00003092\U00007528\U00003044\U0000305f\U000089e3\U00006cd5' does not name a type
35 | メモ化再帰を用いた解法
| ^~~~~~~~~~~~~~~~~~~~~~
a.cc: In function 'int main()':
a.cc:50:3: error: 'solve_dp' was not declared in this scope
50 | solve_dp();
| ^~~~~~~~
a.cc: In function 'int rec_dp(int, int)':
a.cc:34:1: warning: control reaches end of non-void function [-Wreturn-type]
34 | }
| ^
|
s725505503 | p03734 | C++ | 100 990000000
10000000 7584766
10000000 7535949
10000000 7434002
10000000 6224567
10000000 6343925
10000000 6491532
10000000 6704808
10000000 7747279
10000000 7689345
10000000 6003017
10000000 6725907
10000000 7702215
10000000 7686168
10000000 7558917
10000000 6776247
10000000 6545406
10000000 7449047
10000000 7992266
10000000 7751548
10000000 6833032
10000000 7444187
10000000 6819556
10000000 7259985
10000000 6300722
10000000 7233159
10000000 6684330
10000000 6605340
10000000 6874447
10000000 6562109
10000000 7653862
10000000 7409485
10000000 7519891
10000000 7360602
10000000 7819608
10000000 6527920
10000000 6570132
10000000 7651746
10000000 6338431
10000000 7155606
10000000 6025264
10000000 7589982
10000000 6869928
10000000 7630769
10000000 7515380
10000000 6911677
10000000 6674583
10000000 6825273
10000000 6416446
10000000 6623463
10000000 6204563
10000000 6486536
10000000 7600404
10000000 6158906
10000000 7871860
10000000 6719067
10000000 7784027
10000000 7238436
10000000 6605371
10000000 6188240
10000000 7104146
10000000 7365699
10000000 7982853
10000000 6494590
10000000 7174280
10000000 7016579
10000000 7855557
10000000 7668950
10000000 6023444
10000000 7921868
10000000 6042331
10000000 7104691
10000000 6105386
10000000 6067079
10000000 6601243
10000000 6576047
10000000 7848387
10000000 7745981
10000000 6640679
10000000 6669411
10000000 7952639
10000000 7873630
10000000 6199071
10000000 7017695
10000000 6592489
10000000 7848562
10000000 6660501
10000000 7007295
10000000 6296877
10000000 6359013
10000000 7851641
10000000 7555938
10000000 6068489
10000000 7113355
10000000 6953012
10000000 7787784
10000000 6537197
10000000 7825797
10000000 7431682
10000000 7444819
10000003 10000000
| a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 100 990000000
| ^~~
|
s224252290 | p03734 | C++ | #include <iostream>
#include <bits/stdc++.h>
using namespace std;
long long int a[110],b[110],dp[110][110][330];
int main()
{
int n,m;
cin >> n >> m;
for(int i=1;i<=n;i++)
{
cin >> a[i] >> b[i];
}
for(int i=1;i<=n;i++)
{
for(int j=0;j<=i;j++)
{
for(int k=0;k<=3*j;k++){
dp[i+1][j][k] = max(dp[i+1][j][k],dp[i][j][k]);
dp[i+1][j+1][k+a[i]-a[1]] = max(dp[i+1][j+1][k+a[i]-a[1]],dp[i][j][k] + b[i]);
}
}
}
long long int ans = 0;
for(int i=0;i<=n;i++)
{
for(int j=0;j<=3*i;j++){
ll w = a[1]*i + j;
if(w <= m)
ans = max(ans,dp[n+1][i][j]);
}
}
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:30:13: error: 'll' was not declared in this scope
30 | ll w = a[1]*i + j;
| ^~
a.cc:31:16: error: 'w' was not declared in this scope
31 | if(w <= m)
| ^
|
s145816621 | p03734 | C++ | #include <bits/stdc++.h>
using namespace std;
int knapsack(int max_weight, vector<int> weight, vector<int> profit) {
int items_quantity = profit.size();
int knap[items_quantity+1][max_weight+1];
memset(knapsack, 0, sizeof knapsack);
for(int i = 0; i <= items_quantity; i++) {
for(int w = 0; w <= max_weight; w++) {
if (i == 0 || w == 0)
knap[i][w] = 0;
else if (weight[i-1] <= w)
knap[i][w] = max(profit[i-1]+knap[i-1][w-weight[i-1]], knap[i-1][w]);
else
knap[i][w] = knap[i-1][w];
}
}
return knap[items_quantity][max_weight];
}
int main() {
int N, W;
cin >> N >> W;
vector<int> weight(N), profit(N);
for(int i = 0; i < N; i++)
cin >> weight[i] >> profit[i];
int ans = knapsack(W, weight, profit);
cout << ans << '\n';
return 0;
} | a.cc: In function 'int knapsack(int, std::vector<int>, std::vector<int>)':
a.cc:7:32: error: ISO C++ forbids applying 'sizeof' to an expression of function type [-fpermissive]
7 | memset(knapsack, 0, sizeof knapsack);
| ^~~~~~~~
a.cc:7:12: error: invalid conversion from 'int (*)(int, std::vector<int>, std::vector<int>)' to 'void*' [-fpermissive]
7 | memset(knapsack, 0, sizeof knapsack);
| ^~~~~~~~
| |
| int (*)(int, std::vector<int>, std::vector<int>)
In file included from /usr/include/c++/14/cstring:43,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
from a.cc:1:
/usr/include/string.h:61:28: note: initializing argument 1 of 'void* memset(void*, int, size_t)'
61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
| ~~~~~~^~~
|
s932075592 | p03734 | 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 ;
ll dp[110][310][110];//dp[index][weight][choose]
int main(){
ll n,W;
cin >> n >> W;
ll w[n],v[n];
rep(i,n){
cin >> w[i] >> v[i];
}
rep(i,n)sum+=w[i];
ll x=w[0];
rep(i,n)w[i]-=x;
ll sum=0;
rep(i,n+1){
rep(j,301){
rep(k,n){
if(j-w[i]>=0){
dp[i+1][j][k+1]=max(dp[i][j-w[i]][k]+v[i],dp[i][j][k+1]);
}
else{
dp[i+1][j][k+1]=dp[i][j][k+1];
}
}
}
}
ll ans=0;
if(W-n*x>=sum){
ll res=0;
rep(i,n)res+=v[i];
cout << res << endl;
return 0;
}
for(ll i=1;i<=n && W-i*x>=0;i++){
if(W-i*x<=sum)ans=max(ans,dp[n][W-i*x][i]);
}
cout << ans << endl;
return 0;} | a.cc: In function 'int main()':
a.cc:33:11: error: 'sum' was not declared in this scope
33 | rep(i,n)sum+=w[i];
| ^~~
|
s407682875 | p03734 | 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 ;
ll dp[110][310][101];//dp[index][weight][choose]
int main(){
ll n,W;
cin >> n >> W;
ll w[n],v[n];
rep(i,n){
cin >> w[i] >> v[i];
}
rep(i,n)sum+=w[i];
ll x=w[0];
rep(i,n)w[i]-=x;
ll sum=0;
rep(i,n+1){
rep(j,301){
rep(k,n){
if(j-w[i]>=0){
dp[i+1][j][k+1]=max(dp[i][j-w[i]][k]+v[i],dp[i][j][k+1]);
}
else{
dp[i+1][j][k+1]=dp[i][j][k+1];
}
}
}
}
ll ans=0;
if(W-n*x>sum){
ll res=0;
rep(i,n)res+=v[i];
cout << res << endl;
return 0;
}
for(ll i=1;i<=n && W-i*x>=0;i++){
if(W-i*x<=sum)ans=max(ans,dp[n][W-i*x][i]);
}
cout << ans << endl;
return 0;} | a.cc: In function 'int main()':
a.cc:33:11: error: 'sum' was not declared in this scope
33 | rep(i,n)sum+=w[i];
| ^~~
|
s421518412 | p03734 | C++ | #include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
vector<ll> cum_value[5];
ll weights[5];
ll n, w;
int dfs(int index, ll weight, ll value)
{
if (weight > w) return 0;
if (index > 4 or cum_value[index].size() == 0)
return value;
int ans = 0;
rep(i, 0, cum_value[index].size())
{
ans = max(ans, dfs(index + 1, weight + weights[index] * i, value + cum_value[index][i]));
// cout << cum_value[index][i]<<' '<<weight << endl;
}
return ans;
}
int main()
{
cin >> n >> w;
map<int, vector<int>> w_vec;
rep(i, 0, n)
{
int w, v;
cin >> w >> v;
w_vec[w].push_back(v);
}
int index = 0;
for (auto w_v :w_vec)
{
weights[index] = w_v.first;
vector<ll> values = w_v.second;
sort(values.rbegin(), values.rend());
cum_value[index].push_back(0);
for (auto v: values)
{
ll prev = cum_value[index].back();
cum_value[index].push_back(prev + v);
}
++index;
}
cout << dfs(0, 0, 0) << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:41:33: error: conversion from 'vector<int>' to non-scalar type 'vector<long long int>' requested
41 | vector<ll> values = w_v.second;
| ~~~~^~~~~~
|
s606449749 | p03734 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;
int main() {
ios::sync_with_stdio(false);
int n, w, a0, a, b, z = 0;
vector<ll> c[4] = {};
cin >> n >> w >> a >> b; a0 = a;
c[0].push_back(b);
for (int i = 1; i < n; i++) cin >> a >> b, c[a - a0].push_back(b);
for (int i = 0; i < 4; i++) sort(c[i].begin(), c[i].end()), reverse(c[i].begin(), c[i].end()), c[i].insert(c[i].begin(), 0);
for (int i = 0; i < 4; i++) for (int j = 1; j < c[i].size(); j++) c[i][j] += c[i][j - 1];
for (int i = 0; i < c[0].size(); i++) for (int j = 0; j < c[1].size(); j++) for (int k = 0; k < c[2].size(); k++) for (int l = 0; l < c[3].size(); l++) if (i * a0 + j * (a0 + 1) + k * (a0 + 2) + l * (a0 + 3) <= w) z = max(z, c[0][i] + c[1][j] + c[2][k] + c[3][l]);
cout << z << '\n';
}
| a.cc: In function 'int main()':
a.cc:16:226: error: no matching function for call to 'max(int&, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)'
16 | for (int i = 0; i < c[0].size(); i++) for (int j = 0; j < c[1].size(); j++) for (int k = 0; k < c[2].size(); k++) for (int l = 0; l < c[3].size(); l++) if (i * a0 + j * (a0 + 1) + k * (a0 + 2) + l * (a0 + 3) <= w) z = max(z, c[0][i] + c[1][j] + c[2][k] + c[3][l]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:16:226: 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'})
16 | for (int i = 0; i < c[0].size(); i++) for (int j = 0; j < c[1].size(); j++) for (int k = 0; k < c[2].size(); k++) for (int l = 0; l < c[3].size(); l++) if (i * a0 + j * (a0 + 1) + k * (a0 + 2) + l * (a0 + 3) <= w) z = max(z, c[0][i] + c[1][j] + c[2][k] + c[3][l]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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:16:226: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
16 | for (int i = 0; i < c[0].size(); i++) for (int j = 0; j < c[1].size(); j++) for (int k = 0; k < c[2].size(); k++) for (int l = 0; l < c[3].size(); l++) if (i * a0 + j * (a0 + 1) + k * (a0 + 2) + l * (a0 + 3) <= w) z = max(z, c[0][i] + c[1][j] + c[2][k] + c[3][l]);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s648342961 | p03734 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001
int main() {
int N, D; cin >> N >> D;
vector<int> W(N);
vector<int> V(N);
int w1 = 0;
for(int i=0; i<N; i++){
cin >> W[i] >> V[i];
if(i==0) w1 = W[0];
W[i] -= w1;
}
vector<vector<vector<int>>> dp(N+1, vector<vector<int>>(N+1, vector<int>(10)));
for(int i=0; i<N; i++){
for(int j=0; j<=i; j++){
for(int k=0; k<10; k++){
if(k-W[i] >= 0) dp[i+1][j+1][k] = max(dp[i][j+1][k], dp[i][j][k-W[i]] + V[i]);
else dp[i+1][j+1][k] = dp[i][j+1][k];
}
}
}
ll ans = 0;
for(int j=0; j<=N; j++){
for(int k=0; k<10; k++){
if(k + w1 * j <= D) ans = max(dp[N][j][k] , ans);
}
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:47:42: error: no matching function for call to 'max(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, ll&)'
47 | if(k + w1 * j <= D) ans = max(dp[N][j][k] , ans);
| ~~~^~~~~~~~~~~~~~~~~~~
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:47:42: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
47 | if(k + w1 * j <= D) ans = max(dp[N][j][k] , ans);
| ~~~^~~~~~~~~~~~~~~~~~~
/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:47:42: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
47 | if(k + w1 * j <= D) ans = max(dp[N][j][k] , ans);
| ~~~^~~~~~~~~~~~~~~~~~~
|
s475740442 | p03734 | C++ | #include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
signed main(){
int N,W;cin>>N>>W;
vector<int>w(N),v(N);
rep(i,N)cin>>w[i]>>v[i];
vector<vector<int>>v4(4),sm(4,vector<int>(101,0));
int w0=w[0];
rep(i,n){int x=w[i]-w0;v4[x].push_back(v[i]);}
rep(i,4){sort(begin(v4[i]),end(v4[i]),greater<int>());}
vector<int>sz(4);
rep(i,4)sz[i]=v4[i].size();
rep(i,4)rep(j,sz[j])sm[i][j+1]=sm[i][j]+v4[i][j];
int ret=0,ans=0;
rep(i,sz[0])rep(j,sz[1])rep(k,sz[2])rep(l,sz[3]){
if(i*w0+j*(w0+1)+k*(w0+2)+l*(w0+3)>W)continue;
ret=0;
ret+=sm[0][i];ret+=sm[1][j];ret+=sm[2][k];ret+=sm[3][l];
ans=max(ans,ret);
}
cout<<ans<<endl;
}
| a.cc: In function 'int main()':
a.cc:12:15: error: 'n' was not declared in this scope
12 | rep(i,n){int x=w[i]-w0;v4[x].push_back(v[i]);}
| ^
a.cc:4:33: note: in definition of macro 'rep'
4 | #define rep(i,n) for(int i=0;i<(n);i++)
| ^
|
s950181806 | p03734 | C++ | #include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
signed main(){
int N,W;cin>>N>>W;
vector<int>w(N),v(N);
rep(i,N)cin>>w[i]>>v[i];
vector<vector<int>>v4(4),sm(4,vector<int>(101,0));
int w0=w[0];
rep(i,n){int x=w[i]-w0;v4[x].push_back(v[i]);}
rep(i,4){sort(begin(v4[i]),end(v4[i]),greater<int>());}
vector<int>sz(4);
rep(i,4)sz[i]=v4[i].size();
rep(i,4)rep(j,sz[j])sm[i][j+1]=sm[i][j]+v4[i][j];
int ret=0,ans=0;
rep(i,sz[0])rep(j,sz[1])rep(k,sz[2])rep(l,sz[3]){
ret=0;
if(i*w0+j*(w0+1)+k*(w0+2)+l*(w0+3)>W)continue;
ret+=sm[0][i];ret+=sm[1][j];ret+=sm[2][k];ret+=sm[3][l];}
ans=max(ans,ret);
}
cout<<ans<<endl;
}
| a.cc: In function 'int main()':
a.cc:12:15: error: 'n' was not declared in this scope
12 | rep(i,n){int x=w[i]-w0;v4[x].push_back(v[i]);}
| ^
a.cc:4:33: note: in definition of macro 'rep'
4 | #define rep(i,n) for(int i=0;i<(n);i++)
| ^
a.cc: At global scope:
a.cc:25:9: error: 'cout' does not name a type
25 | cout<<ans<<endl;
| ^~~~
a.cc:26:1: error: expected declaration before '}' token
26 | }
| ^
|
s385493071 | p03734 | C++ | /*************************************************************************
> File Name: test.cpp
> Author: Akira
> Mail: qaq.febr2.qaq@gmail.com
************************************************************************/
#include<bits/stdc++.h>
typedef long long LL;
const int MaxN = 101;
LL N,W;
LL w[MaxN], v[MaxN];
LL DP[MaxN][4*MaxN][MaxN];
void solve()
{
LL W1 = w[1];
for(int i=1;i<=N;i++)
w[i] = w[i] - W1;
for(int i=1;i<=N;i++)
{
for(int j=0;j<=300;j++)
{
for(int k=1;k<=N;k++)
{
if( j >= w[i] )
DP[i][j][k] = max( DP[i-1][j][k], DP[i-1][j-w[i]][k-1]+v[i]);
else
DP[i][j][k] = DP[i-1][j][k];
}
}
}
LL ans = 0;
for(int j=0;j<=300;j++)
{
for(int k=0;k<=N;k++)
{
if( k*W1+j<=W)
{
ans = max(ans, DP[N][j][k]);
}
}
}
printf("%lld\n", ans);
}
int main()
{
scanf("%lld%lld", &N, &W);
for(int i=1;i<=N;i++) scanf("%lld%lld", &w[i], &v[i]);
solve();
}
| a.cc: In function 'void solve()':
a.cc:28:35: error: 'max' was not declared in this scope; did you mean 'std::max'?
28 | DP[i][j][k] = max( DP[i-1][j][k], DP[i-1][j-w[i]][k-1]+v[i]);
| ^~~
| std::max
In file included from /usr/include/c++/14/algorithm:61,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:7:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
a.cc:41:23: error: 'max' was not declared in this scope; did you mean 'std::max'?
41 | ans = max(ans, DP[N][j][k]);
| ^~~
| std::max
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
|
s247399222 | p03734 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()
template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}
constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD
const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)
int dp[110][31333];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
// cout<<setprecision(10)<<fixed;
int n, W, w[110], v[110];
cin>>n>>W;
REP(i, n){
cin>>w[i]>>v[i];
}
if(w[0]>W){
cout<<0<<'\n';
return 0;
}
int m=300;
ll mi=W/w[0]*m;
CHMIN(mi, n*m);
REP(i, n){
REP(j, mi+1){
dp[i][j]=-1;
}
}
dp[0][0]=0;
REP(i, n){
REP(j, mi+1){
CHMAX(dp[i+1][j], dp[i][j]);
if(dp[i][j]>=0){
int tmp=(j%m+w[i]-w[0]);
CHMAX(dp[i+1][j/m*m+(tmp/w[0]+1)*m+tmp%w[0]], dp[i][j]+v[i]);
}
}
}
int ans=0;
REP(i, mi+1){
CHMAX(ans, dp[n][i]);
}
cout<<ans<<'\n';
return 0;
}
| a.cc: In function 'int main()':
a.cc:48:14: error: no matching function for call to 'CHMIN(ll&, int)'
48 | CHMIN(mi, n*m);
| ~~~~~^~~~~~~~~
a.cc:21:34: note: candidate: 'template<class T> void CHMIN(T&, T)'
21 | template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}
| ^~~~~
a.cc:21:34: note: template argument deduction/substitution failed:
a.cc:48:14: note: deduced conflicting types for parameter 'T' ('long long int' and 'int')
48 | CHMIN(mi, n*m);
| ~~~~~^~~~~~~~~
|
s236349869 | p03734 | C++ | #include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
const ll inf=1e14;
ll dp[105][105][105]={0};
int main(){
ll n,w;
cin>>n>>w;
ll w1,v1;
cin>>w1>>v1;
for(int i=0;i<105;i++){
for(int j=0;j<105;j++){
for(int k=0;k<105;k++) dp[i][j][k]=0;
}
}
dp[0][0][0]=0;
dp[1][0][0]=0;
dp[1][1][0]=v1;
for(ll i=1;i<n;i++){
for(ll j=0;j<105;j++){
for(ll k=0;k<105;k++) dp[i+1][j][k]=dp[i][j][k];
}
ll wn,vn;
cin>>wn>>vn;
for(ll j=0;j<104;j++){
for(ll k=0;k<105;k++){
if(k+wn-w1<105){
dp[i+1][j+1][k+wn-w1]=max(dp[i+1][j+1][k+wn-w1],dp[i][j][k]+vn);
}
}
}
}
ll ans=0;
for(int i=0;i<105;i++){
ll w2=w-i*w1;
if(w2>=0){ for(int k=0;k<=min(w2,104);k++) ans=max(ans,dp[n][i][k]);}
}
cout<<ans<<endl;
}
| a.cc: In function 'int main()':
a.cc:39:34: error: no matching function for call to 'min(ll&, int)'
39 | if(w2>=0){ for(int k=0;k<=min(w2,104);k++) ans=max(ans,dp[n][i][k]);}
| ~~~^~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
233 | min(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed:
a.cc:39:34: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
39 | if(w2>=0){ for(int k=0;k<=min(w2,104);k++) ans=max(ans,dp[n][i][k]);}
| ~~~^~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:2:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
5686 | min(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
5696 | min(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed:
a.cc:39:34: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
39 | if(w2>=0){ for(int k=0;k<=min(w2,104);k++) ans=max(ans,dp[n][i][k]);}
| ~~~^~~~~~~~
|
s566634074 | p03734 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(){
long long N,W;
cin >> N >> W;
long long DP[N+1][W]={};
list<long long> maxw={0};
for (int i=1;i<N;i++){
long long w,v;
cin >> w >> v;
for(long long x:maxw){
if (x+w<=W) DP[i][x+w]=max(DP[i-1][x+w],DP[i-1][x]+v);
}
}
long long ans=0;
for(long long y:maxw){
ans=max(DP[N][y],max);
}
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:17:12: error: no matching function for call to 'max(long long int&, <unresolved overloaded function type>)'
17 | ans=max(DP[N][y],max);
| ~~~^~~~~~~~~~~~~~
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: 'constexpr const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = long long int]'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:36: note: no known conversion for argument 2 from '<unresolved overloaded function type>' to 'const long long int&'
257 | max(const _Tp& __a, const _Tp& __b)
| ~~~~~~~~~~~^~~
/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:12: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
17 | ans=max(DP[N][y],max);
| ~~~^~~~~~~~~~~~~~
|
s462737366 | p03734 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
using namespace std;
int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);
template <typename T>
T gcd(T a, T b) {
if(b == 0) return a;
else return gcd(b, a % b);
}
template <typename T>
T lcm(T a, T b) {
T g = gcd(a, b);
return a / g * b;
}
bool check(vector<int> a, int index, int key){
if(a[index] >= key) return true;
else return false;
}
int lower_bound(vector<int> a, int key){
int left = -1, right = a.size();
while(right - left > 1){
int mid = left + (left + right) / 2;
if(check(a, mid, key)) right = mid;
else left = mid;
}
return right;
}
int main(){
int N, W;
cin >> N >> W;
vector<int> w(N), v(N);
for(int i = 0; i < N; i++) cin >> w[i] >> v[i];
vector<vector<vector<int>>> dp(N + 1, vector<int>(N + 1, vector<int>(3 * N + 1, 0)));
for(int i = 0; i < N; i++){
for(int j = 0; j <= i; j++){
for(int k = 0; k < 3 * j + 1; k++){
if(k - (w[i] - w[0]) >= 0 && j - 1 >= 0){
dp[i][j][k] == max(dp[i][j][k], dp[i - 1][j - 1][k - (w[i] - w[0])] + v[i]);
}
}
}
}
int ans = 0;
for(int j = 0; j <= N; j++){
for(int k = 0; k < 3 * j + 1; k++){
if((int64_t)j * w[0] + k <= W) ans = max(ans, dp[N][j][k]);
}
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:49:87: error: no matching function for call to 'std::vector<int>::vector(int, std::vector<int>)'
49 | vector<vector<vector<int>>> dp(N + 1, vector<int>(N + 1, vector<int>(3 * N + 1, 0)));
| ^
In file included from /usr/include/c++/14/vector:66,
from a.cc:3:
/usr/include/c++/14/bits/stl_vector.h:707:9: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with <template-parameter-2-2> = _InputIterator; _Tp = int; _Alloc = std::allocator<int>]'
707 | vector(_InputIterator __first, _InputIterator __last,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:707:9: note: template argument deduction/substitution failed:
a.cc:49:87: note: deduced conflicting types for parameter '_InputIterator' ('int' and 'std::vector<int>')
49 | vector<vector<vector<int>>> dp(N + 1, vector<int>(N + 1, vector<int>(3 * N + 1, 0)));
| ^
/usr/include/c++/14/bits/stl_vector.h:678:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; allocator_type = std::allocator<int>]'
678 | vector(initializer_list<value_type> __l,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:678:43: note: no known conversion for argument 1 from 'int' to 'std::initializer_list<int>'
678 | vector(initializer_list<value_type> __l,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:659:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, std::__type_identity_t<_Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>; std::__type_identity_t<_Alloc> = std::allocator<int>]'
659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:659:23: note: no known conversion for argument 1 from 'int' to 'std::vector<int>&&'
659 | vector(vector&& __rv, const __type_identity_t<allocator_type>& __m)
| ~~~~~~~~~^~~~
/usr/include/c++/14/bits/stl_vector.h:640:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type) [with _Tp = int; _Alloc = std::allocator<int>; allocator_type = std::allocator<int>; std::false_type = std::false_type]'
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, 2 provided
/usr/include/c++/14/bits/stl_vector.h:635:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type) [with _Tp = int; _Alloc = std::allocator<int>; allocator_type = std::allocator<int>; std::true_type = std::true_type]'
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, 2 provided
/usr/include/c++/14/bits/stl_vector.h:624:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, std::__type_identity_t<_Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>; std::__type_identity_t<_Alloc> = std::allocator<int>]'
624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:624:28: note: no known conversion for argument 1 from 'int' to 'const std::vector<int>&'
624 | vector(const vector& __x, const __type_identity_t<allocator_type>& __a)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]'
620 | vector(vector&&) noexcept = default;
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:620:7: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]'
601 | vector(const vector& __x)
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:601:7: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:569:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const value_type&, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int; value_type = int; allocator_type = std::allocator<int>]'
569 | vector(size_type __n, const value_type& __value,
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:569:47: note: no known conversion for argument 2 from 'std::vector<int>' to 'const std::vector<int>::value_type&' {aka 'const int&'}
569 | vector(size_type __n, const value_type& __value,
| ~~~~~~~~~~~~~~~~~~^~~~~~~
/usr/include/c++/14/bits/stl_vector.h:556:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int; allocator_type = std::allocator<int>]'
556 | vector(size_type __n, const allocator_type& __a = allocator_type())
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:556:51: note: no known conversion for argument 2 from 'std::vector<int>' to 'const std::vector<int>::allocator_type&' {aka 'const std::allocator<int>&'}
556 | vector(size_type __n, const allocator_type& __a = allocator_type())
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; allocator_type = std::allocator<int>]'
542 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:542:7: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = int; _Alloc = std::allocator<int>]'
531 | vector() = default;
| ^~~~~~
/usr/include/c++/14/bits/stl_vector.h:531:7: note: candidate expects 0 arguments, 2 provided
|
s013937114 | p03734 | C++ | #include <bits/stdc++.h>
using namespace std;
int main(void){
int n, W, w_0, w_, v_;
cin >> n >> W;
vector<int> v[4];
for(int i = 0; i < 4; ++i){
v[i].resize(n+10);
}
cin >> w_0 >> v[0][0];
for(int i = 1; i < n; ++i){
cin >> w_ >> v_;
v[w_-w_0].push_back(v_);
}
for(int i = 0; i < 4; ++i){
sort(v[i].rbegin(), v[i].rend());
}
for(int i = 0; i < 4; ++i){
for(int j = 1; j < v[i].size(); ++j){
v[i][j] += v[i][j-1];
}
}
long long value = 0;
for(int i = 0; i <= v[0].size(); ++i){
for(int j = 0; j <= v[1].size(); ++j){
for(int k = 0; k <= v[2].size(); ++k){
for(int l = 0; l <= v[3].size(); ++l){
if(w_0*i+(w_0+1)*j+(w_0+2)*k+(w_0+3)*l>W) continue;
value = max(value,
(i==0?0:v[0][i-1]) +
(j==0?0:v[1][j-1]) +
(k==0?0:v[2][k-1]) +
(l==0?0:v[3][l-1]));
}
}
}
}
cout << value << endl;
return 0;
// vector<int> w(n), v(n), dp[n+1];
// for(int i = 0; i < n; ++i){
// cin >> w[i] >> v[i];
// dp[i].resize(W+10);
// }
// dp[n].resize(W+10);
// for(int i = 0; i < n; ++i){
// for(int j = 0; j <= W; ++j){
// if(j >= w[i]){
// dp[i+1][j] = max(dp[i][j-w[i]]+v[i], dp[i][j]);
// }else{
// dp[i+1][j] = dp[i][j];
// }
// }
// }
// cout << dp[n][W] << endl;
} | a.cc: In function 'int main()':
a.cc:32:52: error: no matching function for call to 'max(long long int&, int)'
32 | value = max(value,
| ~~~^~~~~~~
33 | (i==0?0:v[0][i-1]) +
| ~~~~~~~~~~~~~~~~~~~~
34 | (j==0?0:v[1][j-1]) +
| ~~~~~~~~~~~~~~~~~~~~
35 | (k==0?0:v[2][k-1]) +
| ~~~~~~~~~~~~~~~~~~~~
36 | (l==0?0:v[3][l-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:32:52: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
32 | value = max(value,
| ~~~^~~~~~~
33 | (i==0?0:v[0][i-1]) +
| ~~~~~~~~~~~~~~~~~~~~
34 | (j==0?0:v[1][j-1]) +
| ~~~~~~~~~~~~~~~~~~~~
35 | (k==0?0:v[2][k-1]) +
| ~~~~~~~~~~~~~~~~~~~~
36 | (l==0?0:v[3][l-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:32:52: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
32 | value = max(value,
| ~~~^~~~~~~
33 | (i==0?0:v[0][i-1]) +
| ~~~~~~~~~~~~~~~~~~~~
34 | (j==0?0:v[1][j-1]) +
| ~~~~~~~~~~~~~~~~~~~~
35 | (k==0?0:v[2][k-1]) +
| ~~~~~~~~~~~~~~~~~~~~
36 | (l==0?0:v[3][l-1]));
| ~~~~~~~~~~~~~~~~~~~
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.