submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s820225190 | p03779 | Java | import java.util.Scanner;
public class Sample {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
Scanner scan = new Scanner(System.in);
int X = scan.nextInt();
int sum =0;
int d =0;
int l =0;
int g =0;
for(int i=0;i<=X;i++){
sum += i;
if(X<=sum){
d = i;
break;
}
}
System.out.println(d);
}
} | Main.java:2: error: class Sample is public, should be declared in a file named Sample.java
public class Sample {
^
1 error
|
s509951242 | p03779 | Java | import java.util.Scanner;
public class Sample {
public static void main(String[] args) {
// TODO 自動生成されたメソッド・スタブ
Scanner scan = new Scanner(System.in);
int X = scan.nextInt();
int sum =0;
int d =0;
int l =0;
int g =0;
for(int i=0;i<=X;i++){
sum += i;
if(X-sum>i){
d = X-sum;
}else{
break;
}
}
for(int f =X;f<=1;f--){
for(int i=0;i<=X-f;i++){
sum += i;
if(X-sum>i){
l = X-sum;
}else{
break;
}
if(f>l){
g =f;
}
}
if(g<d){
d=g;
}
System.out.println(d);
}
}
} | Main.java:2: error: class Sample is public, should be declared in a file named Sample.java
public class Sample {
^
1 error
|
s831950312 | p03779 | Java | import java.util.*;
public class ABC056_C{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
long x = sc.nextLong();
long sum = 0;
long i = 0;
while(sum<x){
sum+=(i+1);
i++;
}
System.out.println(i);
return;
}
} | Main.java:2: error: class ABC056_C is public, should be declared in a file named ABC056_C.java
public class ABC056_C{
^
1 error
|
s833926290 | p03779 | Java | import java.util.*;
public class ABC056_C{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
long x = sc.nextLong();
long sum = 0;
long i = 0;
while(sum<x){
sum+=(i+1);
i++;
}
System.out.println(i);
return;
}
} | Main.java:2: error: class ABC056_C is public, should be declared in a file named ABC056_C.java
public class ABC056_C{
^
1 error
|
s078657068 | p03779 | C++ | #include <iostream>
using namespace std;
int main(){
long long int X;
int sum=0;
cin>>X;
for(int i=1 ; ; i++){ //i=0だとわかりにくい
sum+=i;
if(sum>=X){
break;
cout<<i<<endl;
}
}
return 0;
}
| a.cc:1:2: error: extended character is not valid in an identifier
1 | #include <iostream>
| ^
a.cc:1:2: error: invalid preprocessing directive #include\U00003000
1 | #include <iostream>
| ^~~~~~~~~
a.cc: In function 'int main()':
a.cc:6:11: error: 'cin' was not declared in this scope
6 | cin>>X;
| ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
+++ |+#include <iostream>
1 | #include <iostream>
a.cc:11:22: error: 'cout' was not declared in this scope
11 | cout<<i<<endl;
| ^~~~
a.cc:11:22: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:11:31: error: 'endl' was not declared in this scope
11 | cout<<i<<endl;
| ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
+++ |+#include <ostream>
1 | #include <iostream>
|
s258940498 | p03779 | C++ | #include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
using namespace std;
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
// #define MAX 100010
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
long long binpow(long long a,long long b)
{
if (b == 1) return a;
long long res = binpow(a, b/2)%MOD;
if (b % 2) return (res*((res*a)%MOD))%MOD;
else return (res * res)%MOD;
}
long long int fact(long long int a)
{
if(a==0||a==1)
return 1;
long long int ans = 1;
for(int i=a;i>=1;i--)
ans = (ans * i)% MOD;
return ans;
}
long long int ivmod(long long int a)
{
return binpow(a,MOD-2);
}
long long int summ[1000005];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
// #ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
// #endif
int x;
cin>>x;
int temp = x;
long long int finale = 0;
for(int i=0;i<1000000;i++)
{
sum[i] = (i*(i+1))/2;
if(sum[i]>=x)
{
temp = min(temp,i);
finale = sum[i];
break;
}
}
cout<<temp<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:74:9: error: 'sum' was not declared in this scope; did you mean 'summ'?
74 | sum[i] = (i*(i+1))/2;
| ^~~
| summ
|
s336536651 | p03779 | C++ | using namespace std;
int main(){
int n; cin>>n;
int i=1;
for(;i<100000;i++){
if((i*(i+1)/2) < n)continue;
cout<<i<<endl;
break;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:3:8: error: 'cin' was not declared in this scope
3 | int n; cin>>n;
| ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
+++ |+#include <iostream>
1 | using namespace std;
a.cc:7:2: error: 'cout' was not declared in this scope
7 | cout<<i<<endl;
| ^~~~
a.cc:7:2: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:7:11: error: 'endl' was not declared in this scope
7 | cout<<i<<endl;
| ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
+++ |+#include <ostream>
1 | using namespace std;
|
s666090001 | p03779 | C++ | #include<bits/stdc++.h>
using namespace std;
main(){
int x.i=1;
cin>>x;
while(1){
if(ans+i>=x){ans=i;break;}
ans+=i;
i++;
}
cout<<ans<<endl;
} | a.cc:3:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
3 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:4:7: error: expected initializer before '.' token
4 | int x.i=1;
| ^
a.cc:5:7: error: 'x' was not declared in this scope
5 | cin>>x;
| ^
a.cc:7:6: error: 'ans' was not declared in this scope; did you mean 'abs'?
7 | if(ans+i>=x){ans=i;break;}
| ^~~
| abs
a.cc:7:10: error: 'i' was not declared in this scope
7 | if(ans+i>=x){ans=i;break;}
| ^
a.cc:8:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
8 | ans+=i;
| ^~~
| abs
a.cc:8:8: error: 'i' was not declared in this scope
8 | ans+=i;
| ^
a.cc:11:8: error: 'ans' was not declared in this scope; did you mean 'abs'?
11 | cout<<ans<<endl;
| ^~~
| abs
|
s762628235 | p03779 | C | #include <stdio.h>
using namespace std;
int main()
{
int x;
scanf("%d",&x);
int i=0;
int t=0;
while(t<x)
{
i++;
t+=i;
}
printf("%d\n",i);
return 0;
} | main.c:2:1: error: unknown type name 'using'
2 | using namespace std;
| ^~~~~
main.c:2:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'std'
2 | using namespace std;
| ^~~
|
s262386478 | p03779 | Java | import java.util.Scanner;
public class Go_home {
public static void main(String[] args){
Scanner read = new Scanner(System.in);
int x = Integer.parseInt(read.nextLine());
int c = 0;
int sum = 0;
while (sum < x){
c++;
sum += c;
}
System.out.println(c);
}
} | Main.java:2: error: class Go_home is public, should be declared in a file named Go_home.java
public class Go_home {
^
1 error
|
s809212105 | p03779 | Java | import java.util.Scanner;
public static void main(String[] args){
Scanner read = new Scanner(System.in);
int x = Integer.parseInt(read.nextLine());
int c = 0;
int sum = 0;
while (sum < x){
c++;
sum += c;
}
System.out.println(c);
}
| Main.java:3: error: unnamed classes are a preview feature and are disabled by default.
public static void main(String[] args){
^
(use --enable-preview to enable unnamed classes)
1 error
|
s034298883 | p03779 | Java | import java.util.Scanner;
public class Go_home {
public static void main(String[] args){
Scanner read = new Scanner(System.in);
int x = Integer.parseInt(read.nextLine());
int c = 0;
int sum = 0;
while (sum < x){
c++;
sum += c;
}
System.out.println(c);
}
} | Main.java:2: error: class Go_home is public, should be declared in a file named Go_home.java
public class Go_home {
^
1 error
|
s308441739 | p03779 | C++ | #include <iostream>
#include <vector>
using namespace std;
int main() {
int X;
cin >> X;
int answer = 0;
vector<int> list;
int place = 0;
int i = 1;
bool get_answer = false;
list.push_back(place);
while (true) {
sort(list.begin(), list.end());
list.erase(unique(list.begin(), list.end()), list.end());
for (int j = 0; j < list.size(); j++) {
place = list[j];
if (place == X) {
answer = i - 1;
get_answer = true;
break;
}
}
if (get_answer) {
break;
}
int size = list.size();
for (int j = 0; j < size; j++) {
place = list[j];
list.push_back(place);
list.push_back(place - i);
list.push_back(place + i);
}
i++;
}
cout << answer << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:18:5: error: 'sort' was not declared in this scope; did you mean 'short'?
18 | sort(list.begin(), list.end());
| ^~~~
| short
a.cc:19:16: error: 'unique' was not declared in this scope
19 | list.erase(unique(list.begin(), list.end()), list.end());
| ^~~~~~
|
s730065316 | p03779 | C++ | #include<iostream>
#include<vector>
#include<utility>
using namespace std;
int x;
typedef pair<int, int> pp;
vector<pp> q;
int main() {
cin >> x;
q.push_back(pp(-1, 0));
int now = 0;
while (true) {
pp tmp = q[now++];
if (tmp.second == x) {
cout << tmp.first << endl;
return 0;
}
else {
int i = tmp.first + 1;
q.push_back(pp(i, tmp.second - i));
q.push_back(pp(i, tmp.second));
q.push_back(pp(i, tmp.second + i));
}
}
}
~ | a.cc:30:2: error: expected class-name at end of input
30 | ~
| ^
|
s720224495 | p03779 | C++ | #include<iostream>
#include<utility>
using namespace std;
int x;
typedef pair<int, int> pp;
vector<pp> q;
int main() {
cin >> x;
q.push_back(pp(-1, 0));
int now = 0;
while (true) {
pp tmp = q[now++];
if (tmp.second == x) {
cout << tmp.first << endl;
return 0;
}
else {
int i = tmp.first + 1;
q.push_back(pp(i, tmp.second - i));
q.push_back(pp(i, tmp.second));
q.push_back(pp(i, tmp.second + i));
}
}
}
| a.cc:7:1: error: 'vector' does not name a type
7 | vector<pp> q;
| ^~~~~~
a.cc: In function 'int main()':
a.cc:12:5: error: 'q' was not declared in this scope
12 | q.push_back(pp(-1, 0));
| ^
|
s139761787 | p03779 | C++ | #pragma once
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
long long int X,result,time;
int main() {
cin >> X;
for (long long int i = 1; i < 1000000000; i++)
{
if (time >= X) {
break;
}
result++;
time += i;
}
cout << result<< endl;
return 0;
}
| a.cc:1:9: warning: #pragma once in main file
1 | #pragma once
| ^~~~
a.cc:10:24: error: 'long long int time' redeclared as different kind of entity
10 | long long int X,result,time;
| ^~~~
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/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:4:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
76 | extern time_t time (time_t *__timer) __THROW;
| ^~~~
a.cc: In function 'int main()':
a.cc:19:26: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
19 | if (time >= X) {
| ~~~~~^~~~
a.cc:23:22: warning: pointer to a function used in arithmetic [-Wpointer-arith]
23 | time += i;
| ~~~~~^~~~
a.cc:23:22: error: assignment of read-only location 'time'
|
s634733352 | p03779 | C++ | #include <iostream>
#include <vector>
using namespace std;
int X,ans = 0,s = 1;
vector<int > x;
int solve(){
while(true){
vector<int > xx;
for (int i = 0; i < x.size(); ++i)
{
if(find(xx.begin(), xx.end(),x[i]+s) == xx.end())xx.push_back(x[i]+s);
if(find(xx.begin(), xx.end(),x[i]) == xx.end())xx.push_back(x[i]);
if(find(xx.begin(), xx.end(),x[i]-s) == xx.end())xx.push_back(x[i]-s);
if(x[i]+s == X || x[i] == X || x[i]-s == X)return s;
}
x = xx;
s++;
}
}
int main(){
ios::sync_with_stdio(false);
cin >> X;
x.push_back(0);
ans = solve();
cout << ans << "\n";
return 0;
} | a.cc: In function 'int solve()':
a.cc:11:32: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
11 | if(find(xx.begin(), xx.end(),x[i]+s) == xx.end())xx.push_back(x[i]+s);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/bits/locale_facets.h:48,
from /usr/include/c++/14/bits/basic_ios.h:37,
from /usr/include/c++/14/ios:46,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:1:
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
a.cc:11:32: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
11 | if(find(xx.begin(), xx.end(),x[i]+s) == xx.end())xx.push_back(x[i]+s);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:12:32: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
12 | if(find(xx.begin(), xx.end(),x[i]) == xx.end())xx.push_back(x[i]);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
a.cc:12:32: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
12 | if(find(xx.begin(), xx.end(),x[i]) == xx.end())xx.push_back(x[i]);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:13:32: error: no matching function for call to 'find(std::vector<int>::iterator, std::vector<int>::iterator, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
13 | if(find(xx.begin(), xx.end(),x[i]-s) == xx.end())xx.push_back(x[i]-s);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)'
435 | find(istreambuf_iterator<_CharT> __first,
| ^~~~
/usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed:
a.cc:13:32: note: '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' is not derived from 'std::istreambuf_iterator<_CharT>'
13 | if(find(xx.begin(), xx.end(),x[i]-s) == xx.end())xx.push_back(x[i]-s);
| ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
s332967228 | p03779 | C++ |
using namespace std;
int main(void) {
long long x, i, j, ans = 0;
cin >> x;
for (i = 0; ans < x; i++) {
ans += i;
}
cout << i - 1 << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:6:9: error: 'cin' was not declared in this scope
6 | cin >> x;
| ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
+++ |+#include <iostream>
1 |
a.cc:10:9: error: 'cout' was not declared in this scope
10 | cout << i - 1 << endl;
| ^~~~
a.cc:10:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:10:26: error: 'endl' was not declared in this scope
10 | cout << i - 1 << endl;
| ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
+++ |+#include <ostream>
1 |
|
s725902044 | p03779 | C++ | #include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#define rep(i,n) for(int i=0; i<int(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
ll time[100010];
int main() {
int X; cin >> X;
time[0] = 0;
for (int i = 1; i < 100010; i++) {
time[i] = time[i - 1] + i;
}
int ans = 0;
for (int i = 0; i < 100010; i++) {
if (time[i] >= X) {
ans = i;
break;
}
}
cout << ans << endl;
return 0;
} | a.cc:19:15: error: 'll time [100010]' redeclared as different kind of entity
19 | ll time[100010];
| ^
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/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
76 | extern time_t time (time_t *__timer) __THROW;
| ^~~~
a.cc: In function 'int main()':
a.cc:24:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
24 | time[0] = 0;
| ^
a.cc:24:17: error: assignment of read-only location '* time'
24 | time[0] = 0;
| ~~~~~~~~^~~
a.cc:26:23: warning: pointer to a function used in arithmetic [-Wpointer-arith]
26 | time[i] = time[i - 1] + i;
| ^
a.cc:26:37: warning: pointer to a function used in arithmetic [-Wpointer-arith]
26 | time[i] = time[i - 1] + i;
| ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:26:39: warning: pointer to a function used in arithmetic [-Wpointer-arith]
26 | time[i] = time[i - 1] + i;
| ~~~~~~~~~~~~^~~
a.cc:26:25: error: assignment of read-only location '*(time + ((sizetype)i))'
26 | time[i] = time[i - 1] + i;
| ~~~~~~~~^~~~~~~~~~~~~~~~~
a.cc:31:27: warning: pointer to a function used in arithmetic [-Wpointer-arith]
31 | if (time[i] >= X) {
| ^
a.cc:31:29: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
31 | if (time[i] >= X) {
| ~~~~~~~~^~~~
|
s454225073 | p03779 | C++ | #include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#define rep(i,n) for(int i=0; i<int(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
vector<int> time(100010);
int main() {
int X; cin >> X;
time[0] = 0;
for (int i = 1; i < 100010; i++) {
time[i] = time[i - 1] + i;
}
int ans = 0;
for (int i = 0; i < 100010; i++) {
if (time[i] >= X) {
ans = i;
break;
}
}
cout << ans << endl;
return 0;
} | a.cc:19:17: error: 'std::vector<int> time' redeclared as different kind of entity
19 | vector<int> time(100010);
| ^
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/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/time.h:76:15: note: previous declaration 'time_t time(time_t*)'
76 | extern time_t time (time_t *__timer) __THROW;
| ^~~~
a.cc: In function 'int main()':
a.cc:24:15: warning: pointer to a function used in arithmetic [-Wpointer-arith]
24 | time[0] = 0;
| ^
a.cc:24:17: error: assignment of read-only location '* time'
24 | time[0] = 0;
| ~~~~~~~~^~~
a.cc:26:23: warning: pointer to a function used in arithmetic [-Wpointer-arith]
26 | time[i] = time[i - 1] + i;
| ^
a.cc:26:37: warning: pointer to a function used in arithmetic [-Wpointer-arith]
26 | time[i] = time[i - 1] + i;
| ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:26:39: warning: pointer to a function used in arithmetic [-Wpointer-arith]
26 | time[i] = time[i - 1] + i;
| ~~~~~~~~~~~~^~~
a.cc:26:25: error: assignment of read-only location '*(time + ((sizetype)i))'
26 | time[i] = time[i - 1] + i;
| ~~~~~~~~^~~~~~~~~~~~~~~~~
a.cc:31:27: warning: pointer to a function used in arithmetic [-Wpointer-arith]
31 | if (time[i] >= X) {
| ^
a.cc:31:29: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
31 | if (time[i] >= X) {
| ~~~~~~~~^~~~
|
s137240374 | p03779 | C++ | #include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include<queue>
using namespace std;
int gcd(int a,int b) {
if(b == 0)
return a;
return gcd(b,a%b);
}a
int main() {
int x;
while(cin>>x) {
int sum=0;
int i;
for(i=1; sum<=x; i++) {
sum+=i;
if(sum>=x)
break;
}
cout<<i<<endl;
}
return 0;
}
| a.cc:11:2: error: 'a' does not name a type
11 | }a
| ^
|
s154089687 | p03780 | Java |
import java.util.*;
import java.io.*;
public class A {
static class Reader
{
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
public Reader()
{
din = new DataInputStream(System.in);
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public Reader(String file_name) throws IOException
{
din = new DataInputStream(new FileInputStream(file_name));
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public String readLine() throws IOException
{
byte[] buf = new byte[64]; // line length
int cnt = 0, c;
while ((c = read()) != -1)
{
if (c == '\n')
break;
buf[cnt++] = (byte) c;
}
return new String(buf, 0, cnt);
}
public int nextInt() throws IOException
{
int ret = 0;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do
{
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public long nextLong() throws IOException
{
long ret = 0;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
}
while ((c = read()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public double nextDouble() throws IOException
{
double ret = 0, div = 1;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
}
while ((c = read()) >= '0' && c <= '9');
if (c == '.')
{
while ((c = read()) >= '0' && c <= '9')
{
ret += (c - '0') / (div *= 10);
}
}
if (neg)
return -ret;
return ret;
}
private void fillBuffer() throws IOException
{
bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
if (bytesRead == -1)
buffer[0] = -1;
}
private byte read() throws IOException
{
if (bufferPointer == bytesRead)
fillBuffer();
return buffer[bufferPointer++];
}
public void close() throws IOException
{
if (din == null)
return;
din.close();
}
}
private static final int m = 0;
public static void main(String[] args) throws Exception {
Scanner sc=new Scanner(System.in);
PrintWriter out=new PrintWriter(System.out);
int n=sc.nextInt();
int k=sc.nextInt();
int a[]=new int[n];
long sum=0;
for(int i=0;i<n;i++) {
a[i]=sc.nextInt();
sum+=a[i];
}
if(sum<k) {
System.out.println(n);
}else {
ArrayList<Integer> aa=new ArrayList<>();
for(int i=0;i<n;i++) {
if(a[i]<k) {
aa.add(a[i]);
}
}
Collections.sort(aa);
int sum1=0;
int count=0;
for(int i=aa.size()-1;i>=0;i--) {
sum1+=aa.get(i);
count++;
if(sum1>=k) {
break;
}
}
System.out.println(aa.size()-count);
}
}
} | Main.java:4: error: class A is public, should be declared in a file named A.java
public class A {
^
1 error
|
s414291999 | p03780 | C++ | // -----------------------------------
// author : MatsuTaku
// country : Japan
// created : 09/05/20 00:39:46
// -----------------------------------
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#include "../../../library/include/convolution.hpp"
#include "../../../library/include/ntt.hpp"
using Conv = Convolution<Ntt>;
using Poly = Conv::Polynomial;
int main() {
cin.tie(nullptr); ios::sync_with_stdio(false);
int n,k; cin>>n>>k;
vector<int> A(n); for (auto& a:A) cin>>a;
vector<Poly> dpl(n+1, Poly(k, 0));
dpl[0][0] = 1;
for (int i = 1; i <= n; i++) {
auto a = A[i-1];
dpl[i] = dpl[i-1];
for (int j = 0; j < k; j++) {
if (dpl[i-1][j] == 1 and j + a < k) {
dpl[i][j + a] = 1;
}
}
}
vector<Poly> dpr(n+1, Poly(k, 0));
dpr[n][0] = 1;
for (int i = n-1; i >= 0; i--) {
auto a = A[i];
dpr[i] = dpr[i+1];
for (int j = 0; j < k; j++) {
if (dpr[i+1][j] == 1 and j + a < k) {
dpr[i][j + a] = 1;
}
}
}
int ans = n;
Conv conv(k*2);
for (int i = 1; i <= n; i++) {
auto lpr = conv(dpl[i-1], dpr[i]);
bool found = false;
for (int m = max(0, k-A[i-1]); m < k; m++) {
if (lpr[m] != 0) {
found = true;
break;
}
}
if (found)
ans--;
}
cout << ans << endl;
return 0;
}
| a.cc:12:10: fatal error: ../../../library/include/convolution.hpp: No such file or directory
12 | #include "../../../library/include/convolution.hpp"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
|
s245110638 | p03780 | C++ | #include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
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; }
bool cnt[5010][5010];
bool cnt2[5010][5010];
int n,k;
int a[5001];
void solve() {
cin>>n>>k;
rep(i,n) cin>>a[i];
// vii dp[5010];
vii dp2[5010];
cnt[0][0]=1;
for(int i=0;i<n;i++){
// dp[i+1]=dp[i];
for(int j=0;j<=k;j++){
if(cnt[i][j]==0) continue;
cnt[i+1][j]=1;
if(j + a[i] > k) continue;
cnt[i+1][j+a[i]]=1;
}
}
cnt2[n][0]=1;
for(int i=n-1;i>=0;i--){
for(int j=0;j<=k;j++){
if(cnt2[i+1][j]==0) continue;
cnt2[i][j]=1;
if(j + a[i] > k) continue;
cnt2[i][j+a[i]]=1;
}
}
rep(i,n+1){
for(int j=0;j<=k;j++){
if(cnt[i][j]>0){
dp[i].pb(j);
}
}
}
for(int i=0;i<n+1;i++){
for(int j=0;j<=k;j++){
if(cnt2[i][j]==1){
dp2[i].pb(j);
}
}
}
// rep(i,n+1){
// for(ll j : dp[i]) cout<<j<<" ";
// cout<<endl;
// }
// rep(i,n+1){
// for(ll j : dp2[i]) cout<<j<<" ";
// cout<<endl;
// }
int ans=0;
for(int i=0;i<n;i++){
int x = max(0, k-a[i]);
bool ok = true;
for(int j=0;j<=k;j++) {
if(cnt[i][j]==0) continue;
// cout<<"x-j:"<<x-j<<" ";
auto index = lower_bound(dp2[i+1].begin(), dp2[i+1].end(), x - j);
if(index== dp2[i+1].end()){
// cout<<endl;
continue;
}
int y = *index;
// cout<<i<<" "<<j<<" "<<y<<" "<<endl;
if(j + y >= k) continue;
ok = false;
if(!ok) break;
}
if(ok) ans++;
}
cout<<ans<<endl;
}
signed main(){
cin.tie(0);
ios::sync_with_stdio(false);
cout << fixed << setprecision(15);
solve();
return 0;
}
| a.cc: In function 'void solve()':
a.cc:82:17: error: 'dp' was not declared in this scope; did you mean 'dp2'?
82 | dp[i].pb(j);
| ^~
| dp2
|
s256067790 | p03780 | C++ | #include <bits/stdc++.h>
#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif
using namespace std;
vector<int> A(1), T;
bitset<5000> D[5001], D2;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
TEST(freopen("input.txt","r",stdin));
TEST(freopen("output.txt","w",stdout));
TEST(freopen("debug.txt","w",stderr));
int N, K, ans=0;
cin>>N>>K;
for(int i=0;i<N;i++) {
int a;
cin>>a;
if(a<K) A.push_back(a);
}
ans=N=A.size(); ans--;
D[0][0]=D2[0]=1;
for(int i=1;i<N;i++) D[i]=D[i-1]|(D[i-1]<<A[i]);
for(int i=N-1;i>0;i--) {
int k;
T.clear();
for(int j=0;j<K;j++) if(D[i-1][j]) T.push_back(j);
k=T.size()-1;
for(int j=0;j<K;j++) if(D2[j]) {
while(k && j+T[k]>=K) k--;
if(j+T[j]+A[i]>=K) {
ans--;
break;
}
}
D2[j]|=D2[j]<<A[i];
}
cout<<ans<<'\n';
return 0;
}
| a.cc: In function 'int main()':
a.cc:45:20: error: 'j' was not declared in this scope
45 | D2[j]|=D2[j]<<A[i];
| ^
|
s999729837 | p03780 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;
int main() {
ll n,k;
cin >> n >> k;
vec a(n);
for(ll i=0;i<n;i++) cin >> a[i];
sort(a.begin(),a.end());
ll ok=n,ng=-1;
while(ng+1<ok) {
ll m=(ok+ng)/2;
mat dp(n+1,vec(k));
dp[0][0]=1;
for(ll i=0;i<n;i++) {
for(ll j=0;j<k;j++) {
dp[i+1][j]|=dp[i][j];
if(i!=m&&j+a[i]<k) {
dp[i+1][j+a[i]]|=dp[i][j];
}
}
}
ll f=0;
for(ll i=max(k-a[m],0);i<k;i++) {
if(dp[n][i]) f=1;
}
if(f) ok=m;
else ng=m;
}
cout << ng+1 << endl;
} | a.cc: In function 'int main()':
a.cc:31:17: error: no matching function for call to 'max(ll, int)'
31 | for(ll i=max(k-a[m],0);i<k;i++) {
| ~~~^~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:31:17: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
31 | for(ll i=max(k-a[m],0);i<k;i++) {
| ~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:31:17: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
31 | for(ll i=max(k-a[m],0);i<k;i++) {
| ~~~^~~~~~~~~~
|
s343618968 | p03780 | C | #include<stdio.h>
int main(){
int n,k,i,j,l,g,c=0;
int a[5001],dp1[5001][5001],dp2[5001][5001];
scanf("%d%d",&n,&k);
for(i=0;i<n;i++)scanf("%d",&a[i]);
for(i=0;i<=n;i++)for(j=0;j<=k;j++)dp1[i][j]=dp2[i][j]=0;
dp1[0][0]=dp2[n][0]=1;
for(i=0;i<n;i++)for(j=0;j<=k;j++)dp1[i+1][j]=dp1[i][j]|(j<a[i]?0:dp1[i][j-a[i]]);
for(i=n;i>0;i--)for(j=0;j<=k;j++)dp2[i-1][j]=dp2[i][j]|(j<a[i-1]?0:dp2[i][j-a[i-1]]);
for(i=0;i<n;i++){
g=l=0;
for(j=k-1;j>=0;j--){l+=dp2[i+1][k-j-1];if(k-j>a[i])l-=dp2[i+1][k-a[i]-j-1];g|=dp1[i][j]*l;}
if(a[i]<k&&!g)c++;
} | main.c: In function 'main':
main.c:15:3: error: expected declaration or statement at end of input
15 | }
| ^
|
s696705030 | p03780 | Java |
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
long[] a = new long[n];
for(int i = 0; i < n; i++) {
a[i] = sc.nextLong();
}
Arrays.sort(a);
int ans = 0;
int left = 0;
int right = n;
while(left < right) {
int med = (left + right) / 2;
boolean[][] dp = new boolean[n][k];
if(med != 0) {
dp[0][0] = true;
if(a[0] < k) dp[0][(int)a[0]] = true;
} else {
dp[0][0] = true;
if(n > 1) {
dp[1][0] = true;
if(a[1] < k) dp[1][(int)a[1]] = true;
}
}
for(int i = 1; i < n; i++) {
dp[i][0] = true;
for(int j = 1; j < k; j++) {
dp[i][j] = dp[i - 1][j];
if((i != med) && (j >= a[i])) dp[i][j] = (dp[i][j] || dp[i - 1][j - a[i]]);
}
}
int p = 0;
for(int j = (int)Math.max(0, k - a[med]); j < k; j++) {
if(dp[n - 1][j]) p++;
}
if(p == 0) {
left = med + 1;
} else {
ans = med;
right = med;
}
}
System.out.println(n - ans);
}
} | Main.java:34: error: incompatible types: possible lossy conversion from long to int
if((i != med) && (j >= a[i])) dp[i][j] = (dp[i][j] || dp[i - 1][j - a[i]]);
^
1 error
|
s404778451 | p03780 | Java | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
long[] a = new long[n];
for(int i = 0; i < n; i++) {
a[i] = sc.nextLong();
}
Arrays.sort(a);
int ans = 0;
int left = 0;
int right = n;
while(left < right) {
int med = (left + right) / 2;
boolean[][] dp = new boolean[n][k];
if(med != 0) {
dp[0][0] = true;
if(a[0] < k) dp[0][a[0]] = true;
} else {
dp[0][0] = true;
if(n > 1) {
dp[1][0] = true;
if(a[1] < k) dp[1][a[1]] = true;
}
}
for(int i = 1; i < n; i++) {
dp[i][0] = true;
for(int j = 1; j < k; j++) {
dp[i][j] = dp[i - 1][j];
if((i != med) && (j >= a[i])) dp[i][j] = (dp[i][j] || dp[i - 1][j - a[i]]);
}
}
int p = 0;
for(int j = Math.max(0, k - a[med]); j < k; j++) {
if(dp[n - 1][j]) p++;
}
if(p == 0) {
left = med + 1;
} else {
ans = med;
right = med;
}
}
System.out.println(n - ans);
}
} | Main.java:21: error: incompatible types: possible lossy conversion from long to int
if(a[0] < k) dp[0][a[0]] = true;
^
Main.java:26: error: incompatible types: possible lossy conversion from long to int
if(a[1] < k) dp[1][a[1]] = true;
^
Main.java:33: error: incompatible types: possible lossy conversion from long to int
if((i != med) && (j >= a[i])) dp[i][j] = (dp[i][j] || dp[i - 1][j - a[i]]);
^
Main.java:37: error: incompatible types: possible lossy conversion from long to int
for(int j = Math.max(0, k - a[med]); j < k; j++) {
^
4 errors
|
s318320086 | p03780 | C++ | #define SIZE 5005
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
bool dp[SIZE];
int A[SIZE];
P pos[SIZE];
int main()
{
int n,K;
scanf("%d %d",&n,&K);
for(int i=0;i<n;i++) scanf("%d",&A[i]);
sort(A,A+n);
ll sum=0;
for(int i=0;i<n;i++) sum+=A[i];
memset(dp,false,sizeof(dp));
dp[0]=true;
int ret=0;
for(int i=n-1;i>=0;i--)
{
bool up=false;
for(int j=0;j<K;j++)
{
if(dp[j]&&j+sum>=K) up=true;
}
if(!up) ret++;
sum-=A[i];
for(int j=K-1;j>=A[i];j--) dp[j]|=dp[j-A[i]];
}
printf("%d\n",ret);
return 0;
} | a.cc:5:9: error: 'pair' does not name a type
5 | typedef pair <int,int> P;
| ^~~~
a.cc:9:1: error: 'P' does not name a type
9 | P pos[SIZE];
| ^
a.cc: In function 'int main()':
a.cc:14:9: error: 'scanf' was not declared in this scope
14 | scanf("%d %d",&n,&K);
| ^~~~~
a.cc:16:9: error: 'sort' was not declared in this scope; did you mean 'short'?
16 | sort(A,A+n);
| ^~~~
| short
a.cc:19:9: error: 'memset' was not declared in this scope
19 | memset(dp,false,sizeof(dp));
| ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
+++ |+#include <cstring>
1 | #define SIZE 5005
a.cc:33:9: error: 'printf' was not declared in this scope
33 | printf("%d\n",ret);
| ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
+++ |+#include <cstdio>
1 | #define SIZE 5005
|
s431496255 | p03780 | C++ | #include<iostream>
#include<algorithm>
using namespace std;
int main()
{
long long w,a,b,i,j,k,n;
cin>>n>>k;
long long ara[n];
for(i=0;i<n;i++) cin>>ara[i];
sort(ara,ara+n);
for(i=n-1;i>=0;i--){
if(ara[i]<k) {
a=i;
break;
}
}
long long sum=0;
for(i=0;i<=a;i++) sum+=ara[i];
long long count=0;
if(sum<k) {
cout<<n<<endl;
return 0;
}
for(i=0;i<=a;i++){
sum=sum-ara[i];
if(sum>=k) count++;
else {
break;
}
}
cout<<count<<endl;
}
for(i=0;i<=a;i++){
sum=sum-ara[i];
if(sum>=k) count++;
else {
break;
}
}
cout<<count<<endl;
}
| a.cc:34:5: error: expected unqualified-id before 'for'
34 | for(i=0;i<=a;i++){
| ^~~
a.cc:34:13: error: 'i' does not name a type
34 | for(i=0;i<=a;i++){
| ^
a.cc:34:18: error: 'i' does not name a type
34 | for(i=0;i<=a;i++){
| ^
a.cc:41:5: error: 'cout' does not name a type
41 | cout<<count<<endl;
| ^~~~
a.cc:42:1: error: expected declaration before '}' token
42 | }
| ^
|
s259738669 | p03780 | C++ | #include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
int N,K; cin>>N>>K;
vi A(N);
rep(i,0,N) cin>>A[i];
vector<vector<bool>> dp(N+1,vector<bool>(K+1)),cp(N+1,vector<bool>(K+1));
dp[0][0]=1;
rep(i,0,N){
REP(j,0,K){
if(dp[i][j]){
dp[i+1][j]=1;
dp[i+1][min(j+A[i],K)]=1;
}
}
}
cp[N][0]=1;
rep(i,0,N){
int k=N-i;
REP(j,0,K){
if(cp[k][j]){
cp[k-1][j]=1;
cp[k-1][min(j+A[k-1],K)]=1;
}
}
}
int ans=0;
rep(i,0,N){
int sum=0;
int memo=K-1;
rep(j,0,K){
if(F[j]){
for(memo;0<=memo;memo--){
if(F[memo]&&memo+j<K){
sum=max(sum,memo+j);
break;
}
}
}
}
if(sum+A[i]<K) ans++;
}
cout<<ans<<endl;
}
| a.cc: In function 'int main()':
a.cc:48:10: error: 'F' was not declared in this scope
48 | if(F[j]){
| ^
|
s011832997 | p03780 | C++ | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;
signed main() {
int n, k;
cin >> n >> k;
ll a[n];
rep(i, n) {
cin >> a[i];
}
if (n > 400 || k > 400) return 0;
int ans = n;
rep(i, n) {
vector<ll> t;
rep(j, n) {
if (i == j) continue;
t.emplace_back(a[j]);
}
bool dp[n][k];
fill(dp[0], dp[n], false);
dp[0][0] = true;
rep(j, n - 1) {
rep(l, k) {
if (dp[j][l]) {
dp[j + 1][l] = true;
if (l + t[j] >= k) continue;
dp[j + 1][l + t[j]] = true;
}
}
}
for (int j = max(0, k - a[i]); j < k; j++) {
if (dp[n - 1][j]) {
ans--;
break;
}
}
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:38:25: error: no matching function for call to 'max(int, ll)'
38 | for (int j = max(0, k - a[i]); j < k; j++) {
| ~~~^~~~~~~~~~~~~
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:25: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
38 | for (int j = max(0, k - a[i]); j < k; j++) {
| ~~~^~~~~~~~~~~~~
/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:25: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
38 | for (int j = max(0, k - a[i]); j < k; j++) {
| ~~~^~~~~~~~~~~~~
|
s080712874 | p03780 | C++ | #include <bits/stdc++.h>
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(box) box.begin(), box.end()
using namespace std;
using P = pair<int,int>;
using ll = long long;
const long long INF = LLONG_MAX/3;
bool dp[5010][5010]={},dpr[5010][5010]={};
signed main(){
int n,k;
cin>>n>>k;
int a[5010];
rep(i,n){
cin>>a[i];
}
dp[0][0]=true;
dpr[0][0]=true;
rep(i,1,n+1){
rep(j,k)dp[i][j]=dp[i-1][j];
rep(j,k){
if(dp[i-1][j]){
if(j+a[i-1]<k)dp[i][j+a[i-1]]=true;
}
}
}
rep(i,1,n+1){
rep(j,k)dpr[i][j]=dpr[i-1][j];
rep(j,k){
if(dpr[i-1][j]){
if(j+a[n-i]<k)dpr[i][j+a[n-i]]=true;
}
}
}
int cnt=0;
rep(i,n){
int mn=INF;
vector<int> s,t;
rep(j,k){
if(dp[i][j])s.push_back(j);
if(dpr[n-i-1][j])t.push_back(j);
}
rep(j,s.size()){
int l=lower_bound(t.begin(),t.end(),k-s[j]-a[i])-t.begin();
if(l<t.size())chmin(mn,s[j]+a[i]+t[l]);
}
if(mn==INF||mn-a[i]>=k)cnt++;
}
cout<<cnt<<endl;
}
| a.cc: In function 'int main()':
a.cc:55:39: error: 'chmin' was not declared in this scope
55 | if(l<t.size())chmin(mn,s[j]+a[i]+t[l]);
| ^~~~~
|
s906483251 | p03780 | C++ | #ifndef DEBUG
# define NDEBUG
#endif
#include <iostream>
#include <string>
#include <iterator>
#include <utility>
#include <type_traits>
#include <limits>
#include <cassert>
#include <bitset>
#include <vector>
using namespace std;
// template {{{
// misc {{{
using Z = int;
[[maybe_unused]]
constexpr Z INF = numeric_limits<Z>::max() / 3;
// }}}
// debug {{{
template <class T>
using enable_if_sequence_t = enable_if_t<
is_same<
typename iterator_traits<
typename remove_cv_t<remove_reference_t<T>>::iterator
>::iterator_category,
random_access_iterator_tag>{}>;
#ifdef NDEBUG
# define dump(x)
# define debug if (0)
template <class T>
inline T&& ix(T&& value) { return value; }
template <class T, class Index, class... Indices, class = enable_if_sequence_t<T>>
inline auto&& ix(T&& container, Index index, Indices... indices) {
return ix(container[index], indices...);
}
#else
# define dump(x) do { \
cerr << "\e[33m[dump: " << __LINE__ << "] " << (#x) << " = " << x << "\e[0m" << endl; \
} while (0);
# define debug
template <class T>
inline auto&& ix_impl([[maybe_unused]] int line, [[maybe_unused]] const char* code, T&& value) {
return value;
}
template <class T, class Index, class... Indices, class = enable_if_sequence_t<T>>
inline auto&& ix_impl(int line, const char* code, T&& container, Index index, Indices... indices) {
if (index < 0) {
cerr << "\e[31mix: negative index at line " << line << ", ix(" << code << ")\e[0m" << endl;
exit(1);
}
int size = container.size();
if (index >= size) {
cerr << "\e[31mix: index out of range at line " << line << ", ix(" << code << ")\n"
<< "index = " << index << " whereas size = " << size << "\e[0m" << endl;
exit(1);
}
return ix_impl(line, code, container[index], indices...);
}
#define ix(...) ix_impl(__LINE__, #__VA_ARGS__, __VA_ARGS__)
#endif
// }}}
// IO {{{
template <class T>
false_type is_container_impl(...);
template <class T, class = typename T::iterator>
true_type is_container_impl(T);
template <class T>
struct is_container : decltype(is_container_impl<T>(declval<T>())) {};
template <>
struct is_container <string> : std::false_type {};
template <class Container, class = enable_if_t<is_container<Container>{}>>
istream& operator>> (istream& is, Container& cont) {
for (auto& v : cont) is >> v;
return is;
}
template <class Container, class = enable_if_t<is_container<Container>{}>>
ostream& operator<< (ostream& os, Container const& cont) {
bool first = true;
constexpr char sep =
is_container<typename Container::value_type>{} ? '\n' : ' ';
for (auto const& v : cont) {
if (!first) {
os << sep;
}
first = false;
os << v;
}
return os;
}
template <class T, class U>
ostream& operator<< (ostream& os, pair<T, U> p) {
os << '(' << p.first << ", " << p.second << ')';
return os;
}
// }}}
// }}}
template <class T, class F>
T boundary(F is_ok, T ok, T ng) {
while (abs(ok - ng) > 1) {
T m = (ok + ng) / 2;
(is_ok(m) ? ok : ng) = m;
}
return ok;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
Z N, K;
cin >> N >> K;
vector<Z> as(N);
cin >> as;
sort(begin(as), end(as));
dump(as);
auto res = boundary([&] (Z x) {
dump(x);
if (x < 0) return true;
if (x == N) return false;
if (ix(as, x) >= K) return false;
bitset<5001> ok = 1;
for (auto i = 0; i < N; i++)
if (i != x) ok |= ok << ix(as, i);
bool unnecessary = true;
dump(bitset<64>(ok.to_ulong()));
for (auto i = 1; i <= ix(as, x); i++)
unnecessary &= !ok[K - i];
dump(unnecessary);
return unnecessary;
},
-1, N);
cout << (res + 1) << endl;
}
| a.cc: In function 'int main()':
a.cc:120:3: error: 'sort' was not declared in this scope; did you mean 'short'?
120 | sort(begin(as), end(as));
| ^~~~
| short
|
s635663118 | p03780 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
int n,k;
cin >> n >> k;
vector<long>a(n);
int i,j;
for(i=0;i<n;i++){
cin >> a[i];
}
sort(a.begin(),a.end(),greater<long>());
vector<set<long> >num(n);
int tmp = 0;
vector<bool>chk(n,false);
for(i=0;i<n;i++){
num[i].insert(a[i]);
if(a[i]>=k){
tmp++;
chk[i] = true;
}
}
long tmppp = 0:
for(i=tmp;i<n;i++){
tmppp+=a[i];
}
if(tmppp<k)tmp = 99999999;
for(i=tmp;i<n;i++){
for(j=tmp;j<n;j++){
if(i != j && !chk[j]){
set<long>tmpp;
for(auto kk: num[j]){
if(kk+a[i]>=k && kk+a[i]-a[j]<k)chk[j]=true;
else if(kk+a[i]<k)tmpp.insert(kk+a[i]);
}
for(auto kk:tmpp)num[j].insert(kk);
}
}
}
int ans = 0;
for(i=0;i<n;i++){
if(chk[i]==false)ans++;
}
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:22:17: error: expected ',' or ';' before ':' token
22 | long tmppp = 0:
| ^
a.cc:23:20: error: expected ';' before ')' token
23 | for(i=tmp;i<n;i++){
| ^
| ;
|
s287657719 | p03780 | C++ | #include <bits/stdc++.h>
using namespace std;
int n,k;
vector<int> a;
bool ok(int p) {
if(a[p]>=k) return true;
vector<vector<char> > dp(vector<char>(k));
dp[0][0]=true;
for(int i=0;i<n;++i) {
for(int j=0;j<k;++j) {
dp[i+1][j]|=dp[i][j];
if(i==p||j+a[i]>=k) continue;
dp[i+1][j+a[i]]|=dp[i][j];
if(j+a[i]>=k-a[p]&&dp[i+1][j+a[i]]) return true;
}
}
return false;
}
int main() {
cin >> n >> k;
a.resize(n);
for(auto&e:a) cin >> e;
sort(a.begin(),a.end());
int l=-1,r=n;
while(r-l>1) {
int mid=(l+r)/2;
if(ok(mid)) r=mid;
else l=mid;
}
cout << r << endl;
return 0;
} | a.cc: In function 'bool ok(int)':
a.cc:10:33: warning: parentheses were disambiguated as a function declaration [-Wvexing-parse]
10 | vector<vector<char> > dp(vector<char>(k));
| ^~~~~~~~~~~~~~~~~
a.cc:10:33: note: replace parentheses with braces to declare a variable
10 | vector<vector<char> > dp(vector<char>(k));
| ^~~~~~~~~~~~~~~~~
| -
| { -
| }
a.cc:11:13: warning: pointer to a function used in arithmetic [-Wpointer-arith]
11 | dp[0][0]=true;
| ^
a.cc:11:16: warning: pointer to a function used in arithmetic [-Wpointer-arith]
11 | dp[0][0]=true;
| ^
a.cc:11:17: error: assignment of read-only location '* dp'
11 | dp[0][0]=true;
| ~~~~~~~~^~~~~
a.cc:14:31: warning: pointer to a function used in arithmetic [-Wpointer-arith]
14 | dp[i+1][j]|=dp[i][j];
| ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:14:34: warning: pointer to a function used in arithmetic [-Wpointer-arith]
14 | dp[i+1][j]|=dp[i][j];
| ^
a.cc:14:41: warning: pointer to a function used in arithmetic [-Wpointer-arith]
14 | dp[i+1][j]|=dp[i][j];
| ^
a.cc:14:44: warning: pointer to a function used in arithmetic [-Wpointer-arith]
14 | dp[i+1][j]|=dp[i][j];
| ^
a.cc:14:35: error: invalid operands of types 'std::vector<std::vector<char> >(std::vector<char>)' and 'std::vector<std::vector<char> > (*)(std::vector<char>)' to binary 'operator|'
14 | dp[i+1][j]|=dp[i][j];
| ~~~~~~~~~~^~~~~~~~~~
a.cc:14:35: note: in evaluation of 'operator|=(class std::vector<std::vector<char> >(class std::vector<char>), class std::vector<std::vector<char> > (*)(class std::vector<char>))'
a.cc:16:31: warning: pointer to a function used in arithmetic [-Wpointer-arith]
16 | dp[i+1][j+a[i]]|=dp[i][j];
| ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:16:39: warning: pointer to a function used in arithmetic [-Wpointer-arith]
16 | dp[i+1][j+a[i]]|=dp[i][j];
| ^
a.cc:16:46: warning: pointer to a function used in arithmetic [-Wpointer-arith]
16 | dp[i+1][j+a[i]]|=dp[i][j];
| ^
a.cc:16:49: warning: pointer to a function used in arithmetic [-Wpointer-arith]
16 | dp[i+1][j+a[i]]|=dp[i][j];
| ^
a.cc:16:40: error: invalid operands of types 'std::vector<std::vector<char> >(std::vector<char>)' and 'std::vector<std::vector<char> > (*)(std::vector<char>)' to binary 'operator|'
16 | dp[i+1][j+a[i]]|=dp[i][j];
| ~~~~~~~~~~~~~~~^~~~~~~~~~
a.cc:16:40: note: in evaluation of 'operator|=(class std::vector<std::vector<char> >(class std::vector<char>), class std::vector<std::vector<char> > (*)(class std::vector<char>))'
a.cc:17:50: warning: pointer to a function used in arithmetic [-Wpointer-arith]
17 | if(j+a[i]>=k-a[p]&&dp[i+1][j+a[i]]) return true;
| ^
cc1plus: warning: pointer to a function used in arithmetic [-Wpointer-arith]
a.cc:17:58: warning: pointer to a function used in arithmetic [-Wpointer-arith]
17 | if(j+a[i]>=k-a[p]&&dp[i+1][j+a[i]]) return true;
| ^
|
s506656549 | p03780 | C++ | #include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>
#include <cstdint>
#include <complex>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
int main() {
int n, k; cin >> n >> k;
vector<ll> a(n); rep(i, n) cin >> a[i];
sort(a.begin(), a.end());
int left = -1;
int right = n;
int mid = (left + right) / 2;
while (right - left > 1) {
mid = (left + right) / 2;
vector<vector<bool>> dp(n+1, vector<bool>(k+1, false));
dp[0][0] = true;
rep(i, n) {
rep(j, k+1) {
if (i == mid) {
dp[i+1][j] |= dp[i][j];
} else {
dp[i+1][j] |= dp[i][j];
if (j + a[i] <= k) {
dp[i+1][j+a[i]] |= dp[i][j];
} else {
dp[i+1][k] |= dp[i][j];
}
}
}
}
if (dp[n][k]) right = mid;
else left = mid;
}
cout << left + 1 << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:50:32: error: no match for 'operator|=' (operand types are 'std::vector<bool>::reference' and 'std::vector<bool>::reference')
50 | dp[i+1][j] |= dp[i][j];
| ~~~~~~~~~~~^~~~~~~~~~~
In file included from /usr/include/c++/14/bits/memory_resource.h:38,
from /usr/include/c++/14/string:68,
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/cstddef:168:3: note: candidate: 'constexpr std::byte& std::operator|=(byte&, byte)'
168 | operator|=(byte& __l, byte __r) noexcept
| ^~~~~~~~
/usr/include/c++/14/cstddef:168:20: note: no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::byte&'
168 | operator|=(byte& __l, byte __r) noexcept
| ~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:104:3: note: candidate: 'constexpr const std::_Ios_Fmtflags& std::operator|=(_Ios_Fmtflags&, _Ios_Fmtflags)'
104 | operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) _GLIBCXX_NOTHROW
| ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:104:29: note: no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Fmtflags&'
104 | operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) _GLIBCXX_NOTHROW
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:154:3: note: candidate: 'constexpr const std::_Ios_Openmode& std::operator|=(_Ios_Openmode&, _Ios_Openmode)'
154 | operator|=(_Ios_Openmode& __a, _Ios_Openmode __b) _GLIBCXX_NOTHROW
| ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:154:29: note: no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Openmode&'
154 | operator|=(_Ios_Openmode& __a, _Ios_Openmode __b) _GLIBCXX_NOTHROW
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:201:3: note: candidate: 'constexpr const std::_Ios_Iostate& std::operator|=(_Ios_Iostate&, _Ios_Iostate)'
201 | operator|=(_Ios_Iostate& __a, _Ios_Iostate __b) _GLIBCXX_NOTHROW
| ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:201:28: note: no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Iostate&'
201 | operator|=(_Ios_Iostate& __a, _Ios_Iostate __b) _GLIBCXX_NOTHROW
| ~~~~~~~~~~~~~~^~~
a.cc:52:32: error: no match for 'operator|=' (operand types are 'std::vector<bool>::reference' and 'std::vector<bool>::reference')
52 | dp[i+1][j] |= dp[i][j];
| ~~~~~~~~~~~^~~~~~~~~~~
/usr/include/c++/14/cstddef:168:3: note: candidate: 'constexpr std::byte& std::operator|=(byte&, byte)'
168 | operator|=(byte& __l, byte __r) noexcept
| ^~~~~~~~
/usr/include/c++/14/cstddef:168:20: note: no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::byte&'
168 | operator|=(byte& __l, byte __r) noexcept
| ~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:104:3: note: candidate: 'constexpr const std::_Ios_Fmtflags& std::operator|=(_Ios_Fmtflags&, _Ios_Fmtflags)'
104 | operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) _GLIBCXX_NOTHROW
| ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:104:29: note: no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Fmtflags&'
104 | operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) _GLIBCXX_NOTHROW
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:154:3: note: candidate: 'constexpr const std::_Ios_Openmode& std::operator|=(_Ios_Openmode&, _Ios_Openmode)'
154 | operator|=(_Ios_Openmode& __a, _Ios_Openmode __b) _GLIBCXX_NOTHROW
| ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:154:29: note: no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Openmode&'
154 | operator|=(_Ios_Openmode& __a, _Ios_Openmode __b) _GLIBCXX_NOTHROW
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:201:3: note: candidate: 'constexpr const std::_Ios_Iostate& std::operator|=(_Ios_Iostate&, _Ios_Iostate)'
201 | operator|=(_Ios_Iostate& __a, _Ios_Iostate __b) _GLIBCXX_NOTHROW
| ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:201:28: note: no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Iostate&'
201 | operator|=(_Ios_Iostate& __a, _Ios_Iostate __b) _GLIBCXX_NOTHROW
| ~~~~~~~~~~~~~~^~~
a.cc:54:41: error: no match for 'operator|=' (operand types are 'std::vector<bool>::reference' and 'std::vector<bool>::reference')
54 | dp[i+1][j+a[i]] |= dp[i][j];
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~
/usr/include/c++/14/cstddef:168:3: note: candidate: 'constexpr std::byte& std::operator|=(byte&, byte)'
168 | operator|=(byte& __l, byte __r) noexcept
| ^~~~~~~~
/usr/include/c++/14/cstddef:168:20: note: no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::byte&'
168 | operator|=(byte& __l, byte __r) noexcept
| ~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:104:3: note: candidate: 'constexpr const std::_Ios_Fmtflags& std::operator|=(_Ios_Fmtflags&, _Ios_Fmtflags)'
104 | operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) _GLIBCXX_NOTHROW
| ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:104:29: note: no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Fmtflags&'
104 | operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) _GLIBCXX_NOTHROW
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:154:3: note: candidate: 'constexpr const std::_Ios_Openmode& std::operator|=(_Ios_Openmode&, _Ios_Openmode)'
154 | operator|=(_Ios_Openmode& __a, _Ios_Openmode __b) _GLIBCXX_NOTHROW
| ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:154:29: note: no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Openmode&'
154 | operator|=(_Ios_Openmode& __a, _Ios_Openmode __b) _GLIBCXX_NOTHROW
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:201:3: note: candidate: 'constexpr const std::_Ios_Iostate& std::operator|=(_Ios_Iostate&, _Ios_Iostate)'
201 | operator|=(_Ios_Iostate& __a, _Ios_Iostate __b) _GLIBCXX_NOTHROW
| ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:201:28: note: no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Iostate&'
201 | operator|=(_Ios_Iostate& __a, _Ios_Iostate __b) _GLIBCXX_NOTHROW
| ~~~~~~~~~~~~~~^~~
a.cc:56:36: error: no match for 'operator|=' (operand types are 'std::vector<bool>::reference' and 'std::vector<bool>::reference')
56 | dp[i+1][k] |= dp[i][j];
| ~~~~~~~~~~~^~~~~~~~~~~
/usr/include/c++/14/cstddef:168:3: note: candidate: 'constexpr std::byte& std::operator|=(byte&, byte)'
168 | operator|=(byte& __l, byte __r) noexcept
| ^~~~~~~~
/usr/include/c++/14/cstddef:168:20: note: no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::byte&'
168 | operator|=(byte& __l, byte __r) noexcept
| ~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:104:3: note: candidate: 'constexpr const std::_Ios_Fmtflags& std::operator|=(_Ios_Fmtflags&, _Ios_Fmtflags)'
104 | operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) _GLIBCXX_NOTHROW
| ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:104:29: note: no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Fmtflags&'
104 | operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) _GLIBCXX_NOTHROW
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:154:3: note: candidate: 'constexpr const std::_Ios_Openmode& std::operator|=(_Ios_Openmode&, _Ios_Openmode)'
154 | operator|=(_Ios_Openmode& __a, _Ios_Openmode __b) _GLIBCXX_NOTHROW
| ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:154:29: note: no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Openmode&'
154 | operator|=(_Ios_Openmode& __a, _Ios_Openmode __b) _GLIBCXX_NOTHROW
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:201:3: note: candidate: 'constexpr const std::_Ios_Iostate& std::operator|=(_Ios_Iostate&, _Ios_Iostate)'
201 | operator|=(_Ios_Iostate& __a, _Ios_Iostate __b) _GLIBCXX_NOTHROW
| ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:201:28: note: no known conversion for argument 1 from 'std::vector<bool>::reference' to 'std::_Ios_Iostate&'
201 | operator|=(_Ios_Iostate& __a, _Ios_Iostate __b) _GLIBCXX_NOTHROW
| ~~~~~~~~~~~~~~^~~
|
s696545513 | p03780 | C++ | #include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x) cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int long long
void solve() {
int n, k; cin >> n >> k;
const int MAX = 5050;
vector<int> a(n);
rep(i, n) {
cin >> a[i];
}
int ans = 0;
rep(i, n) {
bitset<MAX> dp;
dp[0] = 1;
rep(j, n) {
if(i == j) continue;
dp |= (dp << a[i]);
}
int s = max(0, k - a[i]);
for(int j = s; j < k; ++j) {
if(dp[j]) continue;
}
++ans;
}
cout << ans << endl;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
//cout << fixed << setprecision(10);
//init();
solve();
//cout << "finish" << endl;
return 0;
} | a.cc: In function 'void solve()':
a.cc:67:20: error: no matching function for call to 'max(int, long long int)'
67 | int s = max(0, k - a[i]);
| ~~~^~~~~~~~~~~~~
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:67:20: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
67 | int s = max(0, k - a[i]);
| ~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:7:
/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:67:20: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
67 | int s = max(0, k - a[i]);
| ~~~^~~~~~~~~~~~~
|
s784333081 | p03780 | C++ | /**
* code generated by JHelper
* More info: https://github.com/AlexeyDmitriev/JHelper
* @author Gosu_Hiroo
*/
#include <iostream>
#include <fstream>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef int
#define V2(v,size_1, size_2, value) vector<vector<long long>>v(size_1, vector<long long>(size_2, value))
#define V3(v,size_1,size_2,size_3,value) vector<vector<vector<long long>>>v(size_1,vector<vector<long long>>(size_2,vector<long long>(size_3, value)))
#define VI vector<long long>
#define G(g,size_1) vector<vector<long long>>g(size_1, vector<long long>())
#define VVI vector<vector<long long>>
#define VVVI vector<vector<vector<long long>>>
#define SZ(x) ((long long)(x).size())
#define READ ({long long t;cin >> t;t;})
#define PII pair<long long, long long>
#else
#define V2(v,size_1, size_2, value) vector<vector<int>>v(size_1, vector<int>(size_2, value))
#define V3(v,size_1,size_2,size_3,value) vector<vector<vector<int>>>v(size_1,vector<vector<int>>(size_2,vector<int>(size_3, value)))
#define VI vector<int>
#define G(g,size_1) vector<vector<int>>g(size_1, vector<int>())
#define SZ(x) ((int)(x).size())
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define READ ({int t;cin >> t;t;})
#define PII pair<int, int>
#endif
#define VM2(v,size_1, size_2, value) vector<vector<mint>>v(size_1, vector<mint>(size_2, value))
#define VM3(v,size_1,size_2,size_3,value) vector<vector<vector<mint>>>v(size_1,vector<vector<mint>>(size_2,vector<mint>(size_3, value)))
#define VM vector<mint>
#define VVM vector<vector<mint>>
#define VVVM vector<vector<vector<mint>>>
#define TR(container, it) \
for (auto it = container.begin(); it != container.end(); it++)
#define IN(c, x) ((c).find(x) != (c).end()) //O(log n)
#define IN_L(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define FOR(i, _begin, _end) for (__typeof(_end) end = _end, begin = _begin, i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define REP(i, end) for (__typeof(end) i = 0, _len = (end); i < (_len); i += 1)
#define ALL(x) (x).begin(),(x).end()
#define F first
#define S second
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define MOD(x, m) ((((x) % (m)) + (m)) % (m))
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define EB emplace_back
#define PB push_back
#define fcout cout << fixed << setprecision(12)
#define fcerr cerr << fixed << setprecision(12)
#define print(x) cout << (x) << endl
# define BYE(a) do { cout << (a) << endl; return ; } while (false)
#ifdef DEBUG
#define ERR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); _err(cerr,_it, args); }
#define DBG(x) cerr << #x << " is " << x << endl;
#else
#define DBG(x) {};
#define ERR(args...) {};
#endif
void _err(std::ostream& cerr,istream_iterator<string> it) {cerr << endl;}
template<typename T, typename... Args>
void _err(std::ostream& cerr, istream_iterator<string> it, T a, Args... args) {
cerr << *it << " = " << a << " ";
_err(cerr,++it, args...);
}
const double pi = 2 * acos(.0);
const int inf = 0x3f3f3f3f;
const ll mod = (ll) (1e9) + 7;
//const ll mod = (ll) 998244353 ;
const double eps = 1e-10;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
std::fill((T *) array, (T *) (array + N), val);
}
template <typename T>
ostream& operator << (ostream& os, const vector<T> V) {
os << "[";
int cnt = 0;
T curr;
if(!V.empty()){
for (int i = 0; i < V.size() - 1; ++i) {
if(V[i] == curr)cnt ++;
else cnt = 0;
if(cnt == 4)os << "... ";
if(cnt < 4)
os << V[i] << " ";
curr = V[i];
}
os << V.back();
}
os << "]";
return os;
}
template <typename T, typename U>
ostream& operator << (ostream& os, const pair<T,U> P) {
os << "(";
os << P.first << "," << P.second;
os << ")";
return os;
}
template <typename T, typename U>
ostream& operator << (ostream& os, const set<T,U> V) {
os << "{";
if(!V.empty()){
auto it = V.begin();
for (int i = 0; i < V.size() -1; ++i) {
os << *it << " ";
it++;
}
os << *it;
}
os << "}";
return os;
}
template <typename K, typename H, typename P>
ostream& operator << (ostream& os, const unordered_set<K, H, P> V) {
os << "{";
if(!V.empty()){
auto it = V.begin();
for (int i = 0; i < V.size() -1; ++i) {
os << *it << " ";
it++;
}
os << *it;
}
os << "}";
return os;
}
template <typename K, typename C>
ostream& operator << (ostream& os, const multiset<K, C> V) {
os << "{";
if(!V.empty()){
auto it = V.begin();
for (int i = 0; i < V.size() -1; ++i) {
os << *it << " ";
it++;
}
os << *it;
}
os << "}";
return os;
}
template <typename K, typename T, typename C>
ostream& operator << (ostream& os, const map<K,T,C> V) {
os << "{";
if(!V.empty()){
auto it = V.begin();
for (int i = 0; i < V.size() -1; ++i) {
os << "(";
os << it->first << "," << it->second;
os << ") ";
it++;
}
os << "(";
os << it->first << "," << it->second;
os << ")";
}
os << "}";
return os;
}
template <typename K, typename T, typename C>
ostream& operator << (ostream& os, const unordered_map<K,T,C> V) {
os << "{";
if(!V.empty()){
auto it = V.begin();
for (int i = 0; i < V.size() -1; ++i) {
os << "(";
os << it->first << "," << it->second;
os << ") ";
it++;
}
os << "(";
os << it->first << "," << it->second;
os << ")";
}
os << "}";
return os;
}
template <typename T>
ostream& operator << (ostream& os, const deque<T> V) {
os << "[";
if (!V.empty()) {
for (int i = 0; i < V.size() - 1; ++i) {
os << V[i] << "->";
}
if (!V.empty())os << V.back();
}
os << "]";
return os;
};
template <typename T, typename Cont, typename Comp>
ostream& operator << (ostream& os, const priority_queue<T, Cont, Comp> V) {
priority_queue<T, Cont, Comp> _V = V;
os << "[";
if(!_V.empty()){
while(_V.size() > 1){
os << _V.top() << "->";
_V.pop();
}
os << _V.top();
}
os << "]";
return os;
};
template <class F>
struct y_combinator {
F f; // the lambda will be stored here
// a forwarding operator():
template <class... Args>
decltype(auto) operator()(Args&&... args) const {
// we pass ourselves to f, then the arguments.
// the lambda should take the first argument as `auto&& recurse` or similar.
return f(*this, std::forward<Args>(args)...);
}
};
// helper function that deduces the type of the lambda:
template <class F>
y_combinator<std::decay_t<F>> recursive(F&& f){
return {std::forward<F>(f)};
}
struct hash_pair {
template <class T1, class T2>
size_t operator()(const pair<T1, T2>& p) const
{
auto hash1 = hash<T1>{}(p.first);
auto hash2 = hash<T2>{}(p.second);
return hash1 ^ hash2;
}
};
/*
struct X{
int x,y,id;
bool operator < (const X R)const{
return id < R.id;
}
friend ostream& operator << (ostream& os, X R){
os << "(" << R.x << "," << R.y << "," << R.id << ")";
}
friend bool operator == (const X L, const X R){
return L.id == R.id;
}
*/
template<class T>void Chmod(T &a, const T &m) {a = MOD(a, m);}
template<class T>bool Chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool Chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
//256MB = 2^29(~5.3*10^8)*sizeof(int)
//#define int ll //2^31=2.15*10^9, 2^63=9.22*10^18
class DNoNeed {
public:
void solve(std::istream& cin, std::ostream& cout, std::ostream& cerr) {
int N, K;
cin >> N >> K;
VI a(N);
REP(i,N)cin >> a[i];
vector<set<int>> L(N+1), R(N+1);
L[0] = {0}, R[N] = {0};
int ans = 0;
REP(i,N){
L[i+1] = L[i];
for(auto t : L[i])if(t + a[i] <= K)L[i+1].insert(t + a[i]);
}
FOR(i,N,0){
R[i] = R[i+1];
for(auto t : R[i+1])if(t + a[i] <= K)R[i].insert(t + a[i]);
}
REP(rmv, N){
auto f= [&](){
ERR(L[rmv], R[rmv+1])
auto p_L = L[rmv].begin(); auto p_R = R[rmv+1].rbegin();
while(p_L != L[rmv].end() && p_R != R[rmv+1].rend()){
while(p_L != L[rmv].end() && p_R != R[rmv+1].rend() && (*p_L + *p_R )< max(1ll, K - a[rmv]))p_L++;
if(p_L == L[rmv].end() || p_R == R[rmv+1].rend())return 1;
if(*p_L + *p_R < K)return 0;
while(p_L != L[rmv].end() && p_R != R[rmv+1].rend() &&( *p_L + *p_R) >= K)p_R++;
if(p_L == L[rmv].end() || p_R == R[rmv+1].rend())return 1;
if(*p_L + *p_R >= max(1ll, K - a[rmv]))return 0;
}
};
ans += f();
}
print(ans);
}
};
#undef int
int main() {
DNoNeed solver;
std::istream& in(std::cin);
std::ostream& out(std::cout);
std::ostringstream err;
in.tie(0); ios::sync_with_stdio(0);
// solver.solve(in, out);
solver.solve(in, out,err);
return 0;
}
| a.cc: In lambda function:
a.cc:301:91: error: no matching function for call to 'max(long long int, int)'
301 | while(p_L != L[rmv].end() && p_R != R[rmv+1].rend() && (*p_L + *p_R )< max(1ll, K - a[rmv]))p_L++;
| ~~~^~~~~~~~~~~~~~~~~
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:7:
/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:301:91: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
301 | while(p_L != L[rmv].end() && p_R != R[rmv+1].rend() && (*p_L + *p_R )< max(1ll, K - a[rmv]))p_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,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:10:
/usr/include/c++/14/bits/stl_algo.h: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:301:91: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
301 | while(p_L != L[rmv].end() && p_R != R[rmv+1].rend() && (*p_L + *p_R )< max(1ll, K - a[rmv]))p_L++;
| ~~~^~~~~~~~~~~~~~~~~
a.cc:306:38: error: no matching function for call to 'max(long long int, int)'
306 | if(*p_L + *p_R >= max(1ll, K - a[rmv]))return 0;
| ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:306:38: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
306 | if(*p_L + *p_R >= max(1ll, K - a[rmv]))return 0;
| ~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:306:38: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
306 | if(*p_L + *p_R >= max(1ll, K - a[rmv]))return 0;
| ~~~^~~~~~~~~~~~~~~~~
a.cc:308:9: warning: control reaches end of non-void function [-Wreturn-type]
308 | };
| ^
|
s178296735 | p03780 | C++ | #include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define MOD 10e9+7
int main(){
int N, K; cin >> N >> K;
int a[N]; rep(i, N) cin >> a[i];
sort(a,a+N,greater<int>());
int cnt = N;
for(int i=0; i<N){
long int sum = 0;
for(int j=i; j<N; j++){
sum += a[j];
if(sum >= K){
cnt = N-(j+1);
i = j+1;
break;
}
}
if( sum < K) break;
}
cout << cnt;
} | a.cc: In function 'int main()':
a.cc:12:21: error: expected ';' before ')' token
12 | for(int i=0; i<N){
| ^
| ;
|
s921310931 | p03780 | C++ | #include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define MOD 10e9+7
int main(){
int N, K; cin >> N >> K;
int a[N]; rep(i, N) cin >> a[i];
sort(a,a+N,greater<int>());
int cnt = N;
for(int i=0; i<N){
long int sum = 0;
for(int j=i; j<N; j++){
sum += a[j];
if(sum >= K){
cnt = N-(j+1);
i = j+1;
break;
}
}
if(sum < K) break;
}
cout << cnt;
}
6 20
25 10 10 4 3 2 | a.cc: In function 'int main()':
a.cc:12:21: error: expected ';' before ')' token
12 | for(int i=0; i<N){
| ^
| ;
a.cc: At global scope:
a.cc:27:1: error: expected unqualified-id before numeric constant
27 | 6 20
| ^
|
s696961186 | p03780 | C++ | #include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=1;i<=(n);i++)
#define rep0(i,n) for(int i=0;i<(n);i++)
const ll INF=1e9+7;
int n,m,a[5001],l,r;
bool jl[INF];
bool dp[5001];
bool check(int k){
// cout<<k<<endl;
memset(dp,0,sizeof(dp));
dp[0]=1;
rep(i,n){
if(i==k){
continue;
}
for(int j=m-a[i];j>=0;j--){
dp[j+a[i]]|=dp[j];
}
/*rep0(j,g){
cout<<dp[j]<<' ';
}
cout<<endl;*/
}
ll t=max(m-a[k],m-m);
// cout<<t<<endl;
for(int i=t;i<=m-1;i++){
if(dp[i]){
return 0;
}
}
return 1;
}
int hash(int a,int b){
return (a*101+b*37)%INF;
}
int main()
{
/*freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);*/
cin>>n>>m;
rep(i,n){
cin>>a[i];
}
sort(a+1,a+n+1);
l=1;
r=n;
while(l<=r){
ll mid=(l+r)/2;
if(check(mid)){
// cout<<1<<' '<<mid<<endl<<endl;
l=mid+1;
}
else{
// cout<<0<<' '<<mid<<endl<<endl;
r=mid-1;
}
if(jl[hash(l,r)]){
break;
}
jl[hash(l,r)]=1;
}
cout<<(l+r)/2;
return 0;
} | a.cc: In function 'int main()':
a.cc:62:23: error: reference to 'hash' is ambiguous
62 | if(jl[hash(l,r)]){
| ^~~~
In file included from /usr/include/c++/14/string_view:50,
from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
from a.cc:1:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
59 | struct hash;
| ^~~~
a.cc:38:5: note: 'int hash(int, int)'
38 | int hash(int a,int b){
| ^~~~
a.cc:65:20: error: reference to 'hash' is ambiguous
65 | jl[hash(l,r)]=1;
| ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
59 | struct hash;
| ^~~~
a.cc:38:5: note: 'int hash(int, int)'
38 | int hash(int a,int b){
| ^~~~
|
s770630887 | p03780 | C++ | #include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=1;i<=(n);i++)
#define rep0(i,n) for(ll i=0;i<(n);i++)
const ll INF=1e9+7;
ll n,m,a[5001],g,l,r;
bool jl[INF];
bool dp[5001];
bool check(int k){
// cout<<k<<endl;
memset(dp,0,sizeof(dp));
dp[0]=1;
rep(i,n){
if(i==k){
continue;
}
for(ll j=g-a[i];j>=0;j--){
dp[j+a[i]]|=dp[j];
}
/*rep0(j,g){
cout<<dp[j]<<' ';
}
cout<<endl;*/
}
ll t=max(m-a[k],m-m);
// cout<<t<<endl;
for(ll i=t;i<=m-1;i++){
if(dp[i]){
return 0;
}
}
return 1;
}
ll hash(ll a,ll b){
return (a*101+b*37)%INF;
}
int main()
{
/*freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);*/
cin>>n>>m;
rep(i,n){
cin>>a[i];
g+=a[i];
}
sort(a+1,a+n+1);
l=1;
r=n;
while(l<=r){
ll mid=(l+r)/2;
if(check(mid)){
// cout<<1<<' '<<mid<<endl<<endl;
l=mid+1;
}
else{
// cout<<0<<' '<<mid<<endl<<endl;
r=mid-1;
}
if(jl[hash(l,r)]){
break;
}
jl[hash(l,r)]=1;
}
cout<<(l+r)/2;
return 0;
} | a.cc: In function 'int main()':
a.cc:63:23: error: reference to 'hash' is ambiguous
63 | if(jl[hash(l,r)]){
| ^~~~
In file included from /usr/include/c++/14/string_view:50,
from /usr/include/c++/14/bits/basic_string.h:47,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
from a.cc:1:
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
59 | struct hash;
| ^~~~
a.cc:38:4: note: 'long long int hash(long long int, long long int)'
38 | ll hash(ll a,ll b){
| ^~~~
a.cc:66:20: error: reference to 'hash' is ambiguous
66 | jl[hash(l,r)]=1;
| ^~~~
/usr/include/c++/14/bits/functional_hash.h:59:12: note: candidates are: 'template<class _Tp> struct std::hash'
59 | struct hash;
| ^~~~
a.cc:38:4: note: 'long long int hash(long long int, long long int)'
38 | ll hash(ll a,ll b){
| ^~~~
|
s163905307 | p03780 | C++ | #include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define moder 1000000007
#define double long double
#define INF LLONG_MAX/10000
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, k, a[5010];
int dp[2][5010][5010];
signed main() {
cin >> n >> k;
rep(i, n)cin >> a[i];
rep(i, n) {
if (!i) {
dp[0][i][0] = 1;
dp[0][i][a[i]] = 1;
continue;
}
rep(j, k) {
if (j - a[i] >= 0)dp[0][i][j] |= (bool)dp[0][i - 1][j - a[i]];
dp[0][i][j] |= (bool)dp[0][i - 1][j];
}
}
rep(i, n) {
rep(j, k) {
if (j)dp[0][i][j] += dp[0][i][j - 1];
}
}
for (int i = n - 1; i >= 0; i--) {
if (i == n - 1) {
dp[1][i][0] = 1;
dp[1][i][a[i]] = 1;
continue;
}
rep(j, k) {
if (j - a[i] >= 0)dp[1][i][j] |= (bool)dp[1][i + 1][j - a[i]];
dp[1][i][j] |= (bool)dp[1][i + 1][j];
}
}
rep(i, n) {
rep(j, k) {
if (j)dp[1][i][j] += dp[1][i][j - 1];
}
}
int ans = 0;
if (dp[1][1][k - 1] == dp[1][1][max((ll)0,k - a[0]]))ans++;
for (int i = 1; i < n - 1; i++) {
bool f = false;
for (int j = 1; j < k; j++) {
if (dp[0][i - 1][j - 1] != dp[0][i - 1][j] && dp[1][i + 1][max((ll)0, k - j - a[i])] != dp[1][i + 1][k - j - 1])f = true;
}
if (!f)ans++;
}
if (dp[0][n - 2][k - 1] == dp[0][n - 2][max((ll)0,k - a[n - 1])])ans++;
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:65:59: error: expected ')' before ']' token
65 | if (dp[1][1][k - 1] == dp[1][1][max((ll)0,k - a[0]]))ans++;
| ~ ^
| )
a.cc:65:61: error: expected primary-expression before ')' token
65 | if (dp[1][1][k - 1] == dp[1][1][max((ll)0,k - a[0]]))ans++;
| ^
|
s706927988 | p03780 | C++ | #include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
#define all(v) v.begin(),v.end()
int n,k,a[5010];
bool dp1[5010][5010],dp2[5010][5010];
signed main(){
cin>>n>>k;
rep(i,n)cin>>a[i];
dp1[0][0]=true;
rep(i,n-1){
rep(j,k){
if(dp1[i][j])dp1[i+1][j]=true;
if(dp1[i][j]&&j+a[i]<=k)dp1[i+1][j+a[i]]=true;
}
}
dp2[n-1][0]=true;
for(int i=n-1;i>0;i--){
rep(j,k){
if(dp2[i][j])dp2[i-1][j]=true;
if(dp2[i][j]&&j+a[i]<=k)dp2[i-1][j+a[i]]=true;
}
}
int ans=0;
rep(i,n){
vector<int>a1,a2;
rep(j,k+1){
if(dp1[i][j])a1.push_back(j);
if(dp2[i][j])a2.push_back(j);
}
bool flag=true;
for(int x:a1){
if(upper_bound(all(a2),k-x-1)-lower_bound(all(a2),k-x-a[i]))flag=false;
}
if(b==false)ans++;
}
cout<<ans<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:36:20: error: 'b' was not declared in this scope
36 | if(b==false)ans++;
| ^
|
s613713269 | p03780 | C | #include<stdio.h>
#define d_flag 0
int C(const void *a,const void *b){
return *(int*)b-*(int*)a;
}
int main(){
int n,K,count=0;
scanf("%d%d",&n,&K);
int i,a[n];
for(i=0;i<n;i++){
scanf("%d",&a[i]);
if(a[i]>=K){
i--;
n--;
}
}
sqrt(a,n,sizeof(int),C);
if(d_flag) {
for(i=0;i<n;i++)
printf(" %d",a[i]);
printf("\n");
}
int dp[K+1],j,k,flag;
for(i=0;i<n;i++){
if(a[i]>=K)continue;
flag=1;
for(j=0;j<=K;j++){
dp[j]=0;
}
dp[0]=1;
for(k=0;k<n;k++){
if(k==i)continue;
for(j=K-a[k];j>=0;j--){
if(dp[j]==1) {
dp[j+a[k]]=1;
if(j+a[k]>=K-a[i]){
flag=0;
break;
}
}
if(flag==0)break;
}
if(flag==0)break;
}
if(flag==0)continue;
/*
for(j=K-a[i];j<K;j++)
if(dp[j]==1) flag=0;
*/
count++;
if(d_flag){
printf("without a[%d]=%d:\n",i,a[i]);
int kkk;
for(kkk=0;kkk<=K;kkk++)printf(" %d",dp[kkk]);
printf(" ,flag:%d\n",flag);
}
}
printf("%d",count);
}
| main.c: In function 'main':
main.c:18:3: error: implicit declaration of function 'sqrt' [-Wimplicit-function-declaration]
18 | sqrt(a,n,sizeof(int),C);
| ^~~~
main.c:2:1: note: include '<math.h>' or provide a declaration of 'sqrt'
1 | #include<stdio.h>
+++ |+#include <math.h>
2 | #define d_flag 0
main.c:18:3: warning: incompatible implicit declaration of built-in function 'sqrt' [-Wbuiltin-declaration-mismatch]
18 | sqrt(a,n,sizeof(int),C);
| ^~~~
main.c:18:3: note: include '<math.h>' or provide a declaration of 'sqrt'
main.c:18:8: error: incompatible type for argument 1 of 'sqrt'
18 | sqrt(a,n,sizeof(int),C);
| ^
| |
| int *
main.c:18:8: note: expected 'double' but argument is of type 'int *'
main.c:18:3: error: too many arguments to function 'sqrt'
18 | sqrt(a,n,sizeof(int),C);
| ^~~~
|
s626635526 | p03780 | C++ | #include <bits/stdc++.h>
using namespace std;
int main() {
int n, k, i, sum = 0;
cin >> n >> k;
vector<int> a(n);
for(i = 0; i < n; i++){
cin >> a.at(i);
sum += a.at(i);
}
if(sum < k){
cout << n << endl;
}
else{
for(i = 0; i < n; i++){
if(a.at(i) <= sum - k){
count++;
}
}
cout << count << endl;
}
}
| a.cc: In function 'int main()':
a.cc:20:12: error: no post-increment operator for type
20 | count++;
| ^~
a.cc:23:10: error: no match for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and '<unresolved overloaded function type>')
23 | cout << count << endl;
| ~~~~~^~~~~~~~
In file included from /usr/include/c++/14/istream:41,
from /usr/include/c++/14/sstream:40,
from /usr/include/c++/14/complex:45,
from /usr/include/c++/14/ccomplex:39,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127,
from a.cc:1:
/usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'}
116 | operator<<(__ostream_type& (*__pf)(__ostream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]'
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
125 | operator<<(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ^~~~~~~~
/usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::ios_base& (*)(std::ios_base&)'
135 | operator<<(ios_base& (*__pf) (ios_base&))
| ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
174 | operator<<(long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long int'
174 | operator<<(long __n)
| ~~~~~^~~
/usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
178 | operator<<(unsigned long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long unsigned int'
178 | operator<<(unsigned long __n)
| ~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
182 | operator<<(bool __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'bool'
182 | operator<<(bool __n)
| ~~~~~^~~
In file included from /usr/include/c++/14/ostream:1022:
/usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]'
96 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short int'
97 | operator<<(short __n)
| ~~~~~~^~~
/usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
189 | operator<<(unsigned short __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short unsigned int'
189 | operator<<(unsigned short __n)
| ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]'
110 | basic_ostream<_CharT, _Traits>::
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int'
111 | operator<<(int __n)
| ~~~~^~~
/usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
200 | operator<<(unsigned int __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'unsigned int'
200 | operator<<(unsigned int __n)
| ~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
211 | operator<<(long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int'
211 | operator<<(long long __n)
| ~~~~~~~~~~^~~
/usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
215 | operator<<(unsigned long long __n)
| ^~~~~~~~
/usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long unsigned int'
215 | operator<<(unsigned long long __n)
| ~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
231 | operator<<(double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'double'
231 | operator<<(double __f)
| ~~~~~~~^~~
/usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
235 | operator<<(float __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'float'
235 | operator<<(float __f)
| ~~~~~~^~~
/usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
243 | operator<<(long double __f)
| ^~~~~~~~
/usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long double'
243 | operator<<(long double __f)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]'
301 | operator<<(const void* __p)
| ^~~~~~~~
/usr/include/c++/14/ostream:301:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const void*'
301 | operator<<(const void* __p)
| ~~~~~~~~~~~~^~~
/usr/include/c++/14/ostream:306:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::nullptr_t) [with _CharT = char; _Tra |
s133073666 | p03780 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
int main(){
int N, K;cin>>N>>K;
vi a;
a.push_back(0);
for (int i=0;i<N;++i){
int a_;cin>>a_;a.push_back(a_);
}
a.push_back(0);
int left[2][K+1], right[2][K+1];
memset(left, -1, sizeof(left));
memset(right, -1, sizeof(right));
left[0][0]=1;
right[0][0]=1;
vi l_sum[N+2], r_sum[N+2];
l_sum[0].push_back(0);r_sum[N+1].push_back(0);
for (int i=0;i<N+1;++i){
for (int j=0;j<K+1;++j){
if(left[0][j]==1||(j>=a[i+1]&&left[0][j-a[i+1]]==1)) {
left[1][j]=1;
l_sum[i+1].push_back(j);
}
}
left[0]=left[1];
}
for (int i=N+1;i>=1;--i){
for (int j=0;j<K+1;++j){
if(right[0][j]==1||(j>=a[i-1]&&right[0][j-a[i-1]]==1)) {
right[1][j]=1;
r_sum[i-1].push_back(j);
}
}
right[0]=right[1];
}
int ans=0;
for (int i=1;i<N+1;++i){
int L=l_sum[i-1].size();
int patience=1;
for (int l=0;l<L;++l){
int R=r_sum[i+1].size();
int x=lower_bound(r_sum[i+1].begin(), r_sum[i+1].end(), K-l_sum[i-1][l]-a[i])-r_sum[i+1].begin();
if (x>R-1) continue;
if(r_sum[i+1][x]+l_sum[i-1][l]<K) patience=0;
}
if(patience==1) ans++;
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:30:12: error: invalid array assignment
30 | left[0]=left[1];
| ~~~~~~~^~~~~~~~
a.cc:40:13: error: invalid array assignment
40 | right[0]=right[1];
| ~~~~~~~~^~~~~~~~~
|
s104015834 | p03780 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
int main(){
int N, K;cin>>N>>K;
vi a;
a.push_back(0);
for (int i=0;i<N;++i){
int a_;cin>>a_;a.push_back(a_);
}
a.push_back(0);
int left[N+2][K+1], right[N+2][K+1];
memset(left, -1, sizeof(left));
memset(right, -1, sizeof(right));
left[0][0]=1;
right[N+1][0]=1;
for (int i=0;i<N+1;++i){
for (int j=0;j<K+1;++j){
if(left[i][j]==1||(j>=a[i+1]&&left[i][j-a[i+1]]==1)) left[i+1][j]=1;
}
}
for (int i=N+1;i>=1;--i){
for (int j=0;j<K+1;++j){
if(left[i][j]==1||(j>=a[i-1]&&left[i][j-a[i-1]]==1)) left[i-1][j]=1;
}
}
vi l_sum[N+2], r_sum[N+2];
int ans=0;
for (int i=0;i<N+2;++i){
for (int j=0;j<K+1;++j){
if(left[i][j]==1)l_sum[i].push_back(j);
if(right[i][j]==1)r_sum[i].push_back(j);
}
}
for (int i=1;i<N+1;++i){
int L=l_sum[i-1].size();
for (int l=0;l<L;++l){
x=lower_bound(r_sum[i+1].begin(), r_sum[i+1].end(), K-l_sum[i-1][l]-a[i])-l_sum[i-1].begin();
if(r_sum[i+1][x]+l_sum[i-1][l]>=K) ans++;
}
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:46:7: error: 'x' was not declared in this scope
46 | x=lower_bound(r_sum[i+1].begin(), r_sum[i+1].end(), K-l_sum[i-1][l]-a[i])-l_sum[i-1].begin();
| ^
|
s621267055 | p03780 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
int main(){
int N, K;cin>>N>>K;
vi a;
for (int i=0;i<N;++i){
int a_;cin>>a_;a.push_back(a_);
}
int left[N][K], right[N][K];
memset(left, -1, sizeof(left));
memset(right, -1, sizeof(right));
left[0][0]=1;left[0][a[0]]=1;
right[N-1][0]=1;right[N-1][a[N-1]]=1;
for (int i=0;i<N;++i){
for (int j=0;j<K;++j){
if(left[i][j]==1||(j>=a[i+1]&&left[i][j-a[i+1]]==1)) left[i+1][k]=1;
}
}
for (int i=N-1;i>=1;--i){
for (int j=0;j<K;++j){
if(left[i][j]==1||(j>=a[i-1]&&left[i][j-a[i-1]]==1)) left[i-1][k]=1;
}
}
vi l_sum[N], r_sum[N];
int ans=0;
for (int i=0;i<N;++i){
for (int j=0;j<K;++j){
if(left[i][j]==1)l_sum[i].push_back(j);
if(right[i][j]==1)r_sum[i].push_back(j);
}
}
int x=lower_bound(l_sum[N-2].begin(), l_sum[N-2].end(), K-a[N-1])-l_sum[N-2].begin();
if(l_sum[x]>=K) ans++;
x=lower_bound(r_sum[1].begin(), r_sum[1].end(), K-a[0])-r_sum[1].begin();
if(r_sum[x]>=K) ans++;
for (int i=1;i<N-1;++i){
int L=l_sum[i-1].size();
for (int l=0;l<L;++l){
x=lower_bound(r_sum[i+1].begin(), r_sum[i+1].end(), K-l_sum[i-1][l]-a[i])-l_sum[i-1].begin();
if(r_sum[x]+l_sum[i-1][l]>=K) ans++;
}
}
cout << ans << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:21:70: error: 'k' was not declared in this scope
21 | if(left[i][j]==1||(j>=a[i+1]&&left[i][j-a[i+1]]==1)) left[i+1][k]=1;
| ^
a.cc:27:70: error: 'k' was not declared in this scope
27 | if(left[i][j]==1||(j>=a[i-1]&&left[i][j-a[i-1]]==1)) left[i-1][k]=1;
| ^
a.cc:42:14: error: no match for 'operator>=' (operand types are 'vi' {aka 'std::vector<int>'} and 'int')
42 | if(l_sum[x]>=K) ans++;
| ~~~~~~~~^~~
| | |
| | int
| vi {aka std::vector<int>}
In file included from /usr/include/c++/14/regex:68,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181,
from a.cc:1:
/usr/include/c++/14/bits/regex.h:1165:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator>=(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
1165 | operator>=(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1165:5: note: template argument deduction/substitution failed:
a.cc:42:16: note: 'vi' {aka 'std::vector<int>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
42 | if(l_sum[x]>=K) ans++;
| ^
/usr/include/c++/14/bits/regex.h:1248:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator>=(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
1248 | operator>=(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1248:5: note: template argument deduction/substitution failed:
a.cc:42:16: note: 'vi' {aka 'std::vector<int>'} is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>'
42 | if(l_sum[x]>=K) ans++;
| ^
/usr/include/c++/14/bits/regex.h:1341:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator>=(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
1341 | operator>=(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1341:5: note: template argument deduction/substitution failed:
a.cc:42:16: note: 'vi' {aka 'std::vector<int>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
42 | if(l_sum[x]>=K) ans++;
| ^
/usr/include/c++/14/bits/regex.h:1415:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator>=(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
1415 | operator>=(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1415:5: note: template argument deduction/substitution failed:
a.cc:42:16: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
42 | if(l_sum[x]>=K) ans++;
| ^
/usr/include/c++/14/bits/regex.h:1509:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator>=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
1509 | operator>=(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1509:5: note: template argument deduction/substitution failed:
a.cc:42:16: note: 'vi' {aka 'std::vector<int>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
42 | if(l_sum[x]>=K) ans++;
| ^
/usr/include/c++/14/bits/regex.h:1586:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator>=(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
1586 | operator>=(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1586:5: note: template argument deduction/substitution failed:
a.cc:42:16: note: mismatched types 'const std::__cxx11::sub_match<_BiIter>' and 'int'
42 | if(l_sum[x]>=K) ans++;
| ^
/usr/include/c++/14/bits/regex.h:1686:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator>=(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
1686 | operator>=(const sub_match<_Bi_iter>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1686:5: note: template argument deduction/substitution failed:
a.cc:42:16: note: 'vi' {aka 'std::vector<int>'} is not derived from 'const std::__cxx11::sub_match<_BiIter>'
42 | if(l_sum[x]>=K) ans++;
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:1070:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator>=(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
1070 | operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
| ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1070:5: note: template argument deduction/substitution failed:
a.cc:42:16: note: 'vi' {aka 'std::vector<int>'} is not derived from 'const std::pair<_T1, _T2>'
42 | if(l_sum[x]>=K) ans++;
| ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:476:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>=(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
476 | operator>=(const reverse_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:476:5: note: template argument deduction/substitution failed:
a.cc:42:16: note: 'vi' {aka 'std::vector<int>'} is not derived from 'const std::reverse_iterator<_Iterator>'
42 | if(l_sum[x]>=K) ans++;
| ^
/usr/include/c++/14/bits/stl_iterator.h:520:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>=(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
520 | operator>=(const reverse_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:520:5: note: template argument deduction/substitution failed:
a.cc:42:16: note: 'vi' {aka 'std::vector<int>'} is not derived from 'const std::reverse_iterator<_Iterator>'
42 | if(l_sum[x]>=K) ans++;
| ^
/usr/include/c++/14/bits/stl_iterator.h:1724:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator>=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
1724 | operator>=(const move_iterator<_IteratorL>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1724:5: note: template argument deduction/substitution failed:
a.cc:42:16: note: 'vi' {aka 'std::vector<int>'} is not derived from 'const std::move_iterator<_IteratorL>'
42 | if(l_sum[x]>=K) ans++;
| ^
/usr/include/c++/14/bits/stl_iterator.h:1781:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator>=(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
1781 | operator>=(const move_iterator<_Iterator>& __x,
| ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1781:5: note: template argument deduction/substitution failed:
a.cc:42:16: note: 'vi' {aka 'std::vector<int>'} is not derived from 'const std::move_iterator<_IteratorL>'
42 | if(l_sum[x]>=K) ans++;
| ^
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/bitset:52,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/string_view:739:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator>=(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)'
739 | operator>=(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:739:5: note: template argument deduction/substitution failed:
a.cc:42:16: note: 'std::vector<int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
42 | if(l_sum[x]>=K) ans++;
| ^
/usr/include/c++/14/string_view:746: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> >)'
746 | operator>=(basic_string_view<_CharT, _Traits> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:746:5: note: template argument deduction/substitution failed:
a.cc:42:16: note: 'std::vector<int>' is not derived from 'std::basic_string_view<_CharT, _Traits>'
42 | if(l_sum[x]>=K) ans++;
| ^
/usr/include/c++/14/string_view:754: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>)'
754 | operator>=(__type_identity_t<basic_string_view<_CharT, _Traits>> __x,
| ^~~~~~~~
/usr/include/c++/14/string_view:754:5: note: template argument deduction/substitution failed:
a.cc:42:16: note: mismatched types 'std::basic_string_view<_CharT, _Traits>' and 'int'
42 | if(l_sum[x]>=K) ans++;
| ^
/usr/include/c++/14/bits/basic_string.h:3997: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>&)'
3997 | operator>=(const basic_string<_CharT, _Traits, _Alloc>& __lhs,
| ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:3997:5: note: template argument deduction/substitution failed:
a.cc:42:16: note: ' |
s791517994 | p03780 | C++ | #include <stdio.h>
#include <iostream>
#include <vector>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define vec vector<int>
#define All(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
int n;
int k;
vec a;
bool f(int m){
vector<vector<bool>> dp(n,vector<bool>(k+1));
dp[0][0]=true;
if(a[0]<=k)dp[0][k]=0;
rep2(i,1,n-1)rep2(j,0,k+1)dp[i][j]=i==m||j<a[i]?dp[i-1][j]:dp[i-1][j]||dp[i-1][j-a[i]];
rep2(j,k-a[m],k-1)if(dp[n-1][j])return false;
return true;
}
int main(){
n=in();
k=in();
a=vec(n);
rep(i,n)a[i]=in();
sort(All(a));
rep3(i,n-1,0);
int l=0,r=n;
while(l+1<r){
int m=(l+r)/2;
if(f(m))l=m;
else r=m;
}
cout<<r<<endl;
} | a.cc: In function 'int main()':
a.cc:28:5: error: 'sort' was not declared in this scope; did you mean 'short'?
28 | sort(All(a));
| ^~~~
| short
|
s326893726 | p03780 | C++ | #include <cstdio>
#include <algorithm>
#include <cstring>
#define MAXN 5050
#define ll long long
using namespace std;
int a[MAXN], dp[MAXN][MAXN];
int n, k;
/*
dp[i][j]表示从前i个元素中是否可以选择一些数使得它们的和为j
一般情况:dp[i,j] = dp[i-1][j];
状态转移方程:当j大于ai时:dp[i,j] = dp[i-1,j]|dp[i-1,j-ai]
1、排序
2、如果ai是不必要的元素,那么ai之前的元素都是不必要的,因此二分查找ai出现的位置
3、使用check函数判断当前元素x是不是必要的 ,是则返回true 不是返回false
如果x是有用的元素,那么一定可以从n个元素中选择一些元素之和在[k-a[s], k)之间,遍历dp[n][(k-a[i], k)]即可
使用dp判断出所有的存在于这个区间的元素,如果能找到,说明x是有用的元素,返回true
*/
bool check(int x) {
memset(dp, 0, sizeof(dp));
if(x==1) {
dp[2][0] = 1;
dp[2][a[2]] = 1;
for(int i = 3; i <= n; i++)
for(int j = 0; j <= k; j++) {
dp[i][j] = dp[i-1][j];
if(j >= a[i])
dp[i][j] = dp[i-1][j] | dp[i-1][j-a[i]];
}
}
else {
dp[1][0] = 1;
dp[1][a[1]] = 1;
for(int i = 2; i <= n; i++)
for(int j = 0; j <= k; j++) {
dp[i][j] = dp[i-1][j];
if(j >= a[i] && x != i)
dp[i][j] = dp[i-1][j] | dp[i-1][j-a[i]];
}
}
for(int i = k-a[x]; i < k; i++)
if(dp[n][i])
return true;
return false;
}
int main() {
scanf("%d%d", &n, &k);
for(int i = 1; i <= n; i++) {
scanf("%d", &a[i]);
if(a[i] > k) a[i] = k;
}
if(n==1) {
if(a[1] >= k) printf("0\n")
else printf("1\n");
return 0;
}
sort(a+1, a+1+n);
int l = 0, r = n+1;
while(l+1 < r) {
int mid = (l+r) / 2;
if(check(mid)) r = mid;
else l = mid;
}
printf("%d\n", l);
return 0;
} | a.cc: In function 'int main()':
a.cc:54:44: error: expected ';' before 'else'
54 | if(a[1] >= k) printf("0\n")
| ^
| ;
55 | else printf("1\n");
| ~~~~
|
s358535974 | p03780 | C++ | #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<malloc.h>
#include<x86intrin.h>
int my_gets(char *buf,int nBuf,FILE *fp){
int ch;
while(--nBuf >0){
ch=getc(fp);
if(ch==EOF || ch=='\n')
break;
*(buf++)=(char)ch;
}
*(buf)='\0';
return nBuf;
}
int InputIntAry(int *a,int nBuf,int N,int K){
int ret=0;
int64_t tmp;
char *buf,*ptr;
buf=(char*)malloc(nBuf*sizeof(char));
my_gets(buf,nBuf,stdin);
ptr=strtok(buf," ");
while(ptr!=NULL && N-->0){
tmp=atoll(ptr);
if(tmp < K){ //Kより大きなカードは必要に決まっているし, 他のカードの判定に関係しない
a[ret++] = (int)tmp;
//printf("%d\n",a[ret-1]);
}
ptr=strtok(NULL," ");
}
free(buf);
return ret;
}
#define MIN(a,b) ( ((a)<(b))?(a):(b) )
int main(){
int a[5000];
int N,K,cnt=0;
scanf("%d %d%*c",&N,&K);
N=InputIntAry(a,12*N,N,K);
for(int i=0;i<N;i++){
int dp[5001][5000]={},K_i,min=INT_MAX;
K_i = K - a[i];
dp[0][0]=1;
for(int j=0;j<N;j++){
if(j==i){
for(int k=0;k<K_i;k++)
dp[j+1][k] = dp[j][k];
continue;
}
for(int k=0;k<K_i;k++){
if(dp[j][k]){
dp[j+1][k]=1;
if(k+a[j] >= K_i){
min = MIN(k+a[j],min);
}
else{
dp[j+1][k+a[j]] =1;
}
}
}
}
//printf("%d: %d min:%d\n",i,a[i],min);
if(min >= K)
cnt++;
}
printf("%d\n",cnt);
return 0;
} | a.cc: In function 'int main()':
a.cc:54:39: error: 'INT_MAX' was not declared in this scope
54 | int dp[5001][5000]={},K_i,min=INT_MAX;
| ^~~~~~~
a.cc:7:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
6 | #include<x86intrin.h>
+++ |+#include <climits>
7 |
|
s144867115 | p03780 | C++ |
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e20);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a>b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a<b ? : a = b; }
class subsequence
{
private:
int Left, Right;
long long S;
int N;
long long LRsum;
std::vector<long long> sequence;
public:
virtual void move_left_pointer();
virtual void move_right_pointer();
virtual bool is_cond();
virtual bool is_right_end();
virtual std::pair<int, int> no_next();
virtual std::pair<int, int> get_LR();
void set_S(long long S);
subsequence(std::vector<long long>& sequence, int N, int start);
};
subsequence::subsequence(std::vector<long long>& sequence, int N, int start) :
sequence(sequence),
N(N),
Left(start),
Right(start),
S(0),
LRsum(0)
{
}
void subsequence::set_S(long long S) {
this->S = S;
}
void subsequence::move_left_pointer() {
LRsum -= sequence[Left];
Left++;
}
void subsequence::move_right_pointer() {
if (Right < N) {
LRsum += sequence[Right];
Right++;
}
}
bool subsequence::is_cond() {
if (LRsum >= S)
return true;
return false;
}
bool subsequence::is_right_end() {
if (Right >= N)
return true;
return false;
}
std::pair<int, int> subsequence::no_next() {
return std::make_pair(-1, -1);
}
std::pair<int, int> subsequence::get_LR() {
return std::make_pair(Left, Right);
}
int main() {
std::vector<long long> sequence;
int N, K;
std::cin >> N >> K;
for (int i = 0; i < N; i++) {
long long a;
std::cin >> a;
sequence.push_back(a);
}
std::sort(sequence.begin(), sequence.end());
subsequence seq(sequence, sequence.size(), 0);
seq.set_S(K);
int min_len = INT_MAX;
int count = 0;
int left_pointer_move_count = 0;
while (1) {
bool is_break = false;
while (seq.is_cond() == false && seq.is_right_end() == false) {
if (left_pointer_move_count > 0) {
count += (left_pointer_move_count - 1);
is_break = true;
}
left_pointer_move_count = 0;
seq.move_right_pointer();
}
if (is_break == true)
break;
if (seq.is_cond() == false) {
if (left_pointer_move_count > 0)
count += (left_pointer_move_count - 1);
break;
}
seq.move_left_pointer();
left_pointer_move_count++;
}
std::cout << count << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:129:19: error: 'INT_MAX' was not declared in this scope
129 | int min_len = INT_MAX;
| ^~~~~~~
a.cc:30:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
29 | #include <functional>
+++ |+#include <climits>
30 | using namespace std;
|
s423462207 | p03780 | C++ | #include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<string>
//#include<string>
//#include<sstream>
typedef long long ll;
#define N 5050
int a[N]={0};
int main(){
ll n,k;
cin>>n>>k;
for(int i=0; i<n; i++){
cin>>a[i];
}
sort(a,a+n);//排序,容易知道一定是最小的那几个是不需要的
ll sum = 0;
ll p = n;
for(ll i=n-1; i>=0; i--){
if(sum+a[i]<k){
sum +=a[i];
}
else{
p = i;
}
}
cout<<p<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:16:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
16 | cin>>n>>k;
| ^~~
| std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
62 | extern istream cin; ///< Linked to standard input
| ^~~
a.cc:20:5: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
20 | sort(a,a+n);//排序,容易知道一定是最小的那几个是不需要的
| ^~~~
| std::sort
In file included from /usr/include/c++/14/algorithm:86,
from a.cc:2:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
| ^~~~
a.cc:32:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
32 | cout<<p<<endl;
| ^~~~
| std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
63 | extern ostream cout; ///< Linked to standard output
| ^~~~
a.cc:32:14: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
32 | cout<<p<<endl;
| ^~~~
| std::endl
In file included from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
744 | endl(basic_ostream<_CharT, _Traits>& __os)
| ^~~~
|
s124362719 | p03780 | C++ | #include <iostream>
#include <set>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
int a[5001];
int main(int argc, const char * argv[]) {
int n, k;
cin >> n >> k;
int ans = n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
int sum = 0;
for (int i = n - 1; i >= 0; i--) {
if (sum + a[i] < k) {
sum += a[i];
} else {
ans = min(ans, i);
}
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main(int, const char**)':
a.cc:21:3: error: 'sort' was not declared in this scope; did you mean 'short'?
21 | sort(a, a + n);
| ^~~~
| short
|
s115434746 | p03780 | C++ | #include <iostream>
#include <set>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
int main(int argc, const char * argv[]) {
int n, k;
cin >> n >> k;
int a[5001];
int ans = n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
int sum = 0;
for (int i = n - 1; i >= 0; i--) {
if (sum + a[i] < k) {
sum += a[i];
} else {
ans = min(ans, i);
}
}
cout << ans << endl;
return 0;
}
| a.cc: In function 'int main(int, const char**)':
a.cc:20:3: error: 'sort' was not declared in this scope; did you mean 'short'?
20 | sort(a, a + n);
| ^~~~
| short
|
s291669846 | p03780 | C++ | #include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = int64_t;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
fill((T *)array, (T *)(array + N), val);
}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[51][52];
bool dp[5002][5002] = {};
signed main(){
IOS;
ll n, k;
cin >> n >> k;
vec<ll> a(n + 1);
ll sum = 0;
REP(i,n){
cin >> a[i];
sum += a[i];
}
a[n] = 0;
if(sum < k){
dump(n);
return 0;
}
sort(ALL(a),greater<ll>());
ll left = 0, right = n;
ll mid;
while(right - left > 1){
Fill(dp,false);
dp[0][0] = true;
mid = (right + left) / 2;
for(int i = 0;i < n;i++){
for(int j = 0;j < k;j++){
if(i == mid)dp[i + 1][j] = dp[i][j];
else {
dp[i + 1][j] = dp[i][j];
if(j >= a[i])dp[i + 1][j] |= dp[i][j - a[i]];
}
}
}
bool ok = false;
for(int j = max(k - a[mid],0ll);j < k;j++)if(dp[n][j])ok = true;
if(ok)left = mid;
else right = mid;
}
left++;
dump(n - left);
} | a.cc: In function 'int main()':
a.cc:59:24: error: no matching function for call to 'max(ll, long long int)'
59 | for(int j = max(k - a[mid],0ll);j < k;j++)if(dp[n][j])ok = true;
| ~~~^~~~~~~~~~~~~~~~
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:59:24: note: deduced conflicting types for parameter 'const _Tp' ('long int' and 'long long int')
59 | for(int j = max(k - a[mid],0ll);j < k;j++)if(dp[n][j])ok = true;
| ~~~^~~~~~~~~~~~~~~~
/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:59:24: note: mismatched types 'std::initializer_list<_Tp>' and 'long int'
59 | for(int j = max(k - a[mid],0ll);j < k;j++)if(dp[n][j])ok = true;
| ~~~^~~~~~~~~~~~~~~~
|
s386424918 | p03780 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
int main(){
int n, k;
cin >> n >> k;
vector<int> a;
for(int i = 0; i < n; i++){
int ta;
cin >> ta;
if(ta <= k){
a.push_back(ta);
}
}
sort(a.begin(),a.end());
n = a.size();
vector<vector<int>> dp(n+1,vector<int>(k+1,0));
dp[0][0] = 1;
for(int i = 0; i < n; i++){
for(int j = 0; j <= k; j++){
dp[i+1][min(j+a[i],k)] += dp[i][j];
dp[i+1][j] += dp[i][j];
}
}
int ok = -1;
int ng = n;
while (abs(ok - ng) > 1) {
int mid = (ok + ng) / 2;
vector<vector<int>> dp2(n,vector<int>(k+1,0));
dp2[0][0] = 1;
for(int i = 0; i < n-1; i++){
int index = i >= mid ? i+1 : i;
for(int j = 0; j <= k; j++){
dp2[i+1][min(j+a[index],k)] +Q= dp2[i][j];
dp2[i+1][j] += dp2[i][j];
}
}
if (dp2[n-1][k]*2 == dp[n][k]) ok = mid;
else ng = mid;
}
cout << ok + 1 << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:44:46: error: 'Q' was not declared in this scope
44 | dp2[i+1][min(j+a[index],k)] +Q= dp2[i][j];
| ^
|
s167222404 | p03780 | C++ | #include <cstdio>
#include<bitset>
#include<iostream>
#include<string>
#define ll long long
using namespace std;
long long n,k;
ll a[5010];
bitset<5010> bs;
bool check(int x)
{
bs.reset();
bs[0]=1;
for(int i=1;i<=n;i++)
if(i!=x) bs|=(bs<<a[i]);
for(int i=k-a[x];i<k;i++)
if(bs[i]==1) return false;
return true;
}
int main()
{
cin>>n>>k;
for(int i=1;i<=n;i++)
cin>>a[i];
sort(a+1,a+n+1);
int l=0,r=0,mid;
for(int i=n;i>=1;i--)
{
if(a[i]<k)
{
r=i;
break;
}
}
while(l<r)
{
mid=((l+r)>>1)+1;
if(check(mid))
l=mid;
else r=mid-1;
}
cout<<l;
return 0;
}
| a.cc: In function 'int main()':
a.cc:25:9: error: 'sort' was not declared in this scope; did you mean 'short'?
25 | sort(a+1,a+n+1);
| ^~~~
| short
|
s497581004 | p03780 | C++ | #include <cstdio>
#include <algorithm>
#include <bitset>
#define MAXN 50005
#define MAXBS 70005
using namespace std;
bitset<MAXBS> bs;
long long a[MAXN]={0};
long long n=0,k=0;
long long check(long long x);
int main(void){
long long ll=0,rr=0;
scanf("%lld%lld",&n,&k);
for (int i=0;i<n;i++){
scanf("%lld",a+i);
a[i]=min(a[i],k);
}
if (n==1){
printf("%d\n",int(a[0]==k));
return 0;
}
sort(a,a+n);
//(ll,rr]
ll=-1,rr=n+1;
while (rr-ll>1){
long long mid=(ll+rr+1)>>1;
if (check(mid))
rr=mid;
else
ll=mid;
}
printf("%lld\n",ll+1);
return 0;
}
long long check(long long x){
bs.reset(); // bs=0
bs.set(0); // bs[0]=1;
for (long long i=0;i<n;i++)
if (i!=x)
bs|=(bs<<a[i]);
for (long long i=max(0,k-a[x]);i<k;i++){
if (bs.test(i))
return 1;
}
return 0;
} | a.cc: In function 'long long int check(long long int)':
a.cc:42:25: error: no matching function for call to 'max(int, long long int)'
42 | for (long long i=max(0,k-a[x]);i<k;i++){
| ~~~^~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:42:25: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
42 | for (long long i=max(0,k-a[x]);i<k;i++){
| ~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:42:25: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
42 | for (long long i=max(0,k-a[x]);i<k;i++){
| ~~~^~~~~~~~~~
|
s028748630 | p03780 | C++ | #include <cstdio>
#include <algorithm>
#include <bitset>
#define MAXN 5005
#define MAXBS 7005
using namespace std;
bitset<MAXBS> bs;
int a[MAXN];
int n,k;
int check(int x);
int main(void){
int ll,rr;
scanf("%d%d",&n,&k);
for (int i=0;i<n;i++){
scanf("%d",a+i);
a[i]=min(a[i],k);
}
sort(a,a+n);
//[ll,rr)
ll=0,rr=n+1;
while (rr-ll>1){
int mid=(ll+rr)>>1;
if (check(mid))
rr=mid;
else
ll=mid;
}
printf("%d\n",ll+1);
return 0;
}
int check(int x){
bs(0)
bs[0]=1;
for (int i=0;i<n;i++)
if (i!=x)
bs|=(bs<<a[i]);
for (int i=max(0,k-a[x]);i<k;i++){
if (bs[i])
return 1;
}
return 0;
}
| a.cc: In function 'int check(int)':
a.cc:33:7: error: no match for call to '(std::bitset<7005>) (int)'
33 | bs(0)
| ~~^~~
|
s703502497 | p03780 | C++ | #include<iostream>
using namespace std;
int n,s,k,a[5001],dp[5001],vis=1;
int main()
{
ios::sync_with_stdio(false);
cin>>n>>k;
for(int i=1;i<=n;i++)
{
cin>>a[i];
a[i]=min(a[i],k);
s+=a[i];
}
sort(a+1,a+n+1);
dp[0]=1;
for(int i=n;i>=0;i--)
{
vis=1;
for(int j=k-1;j>=k-s and j>=0;j--)
{
if(dp[j])vis=0;
}
if(vis)
{
cout<<i;
break;
}
for(int j=k;j>=a[i];j--)
{
dp[j]|=dp[j-a[i]];
}
s-=a[i];
}
return 0;
} | a.cc: In function 'int main()':
a.cc:14:9: error: 'sort' was not declared in this scope; did you mean 'short'?
14 | sort(a+1,a+n+1);
| ^~~~
| short
|
s234662569 | p03780 | C++ | #include <bits/stdc++.h>
#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
typedef long long ll;
using namespace std;
const int INF = 1e9,MOD = 1e9 + 7,ohara = 1e6;
const ll LINF = 1e18;
long long int n,cnt=0,ans=0,a[ohara],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,k;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl,ok;
struct edge{int to,cost;};
//-------------------------↓↓↓↓↓↓------------------------
int main(void){
cin.tie(0);
ios::sync_with_stdio(false);
cin>>n>>k;
rep(i,n)cin>>a[i];
rep(i,n){
bitset<k+1> dp;
dp[0]=true;
ok=true;
rep(j,n){
if(i==j)continue;
dp|=(dp<<a[j]);
}
if(k<=a[i])continue;
rrep(j,k-a[i],k){
if(dp[j]){
ok=false;
break;
}
}
if(ok)ans++;
}
Cout(ans);
return 0;
}
| a.cc: In function 'int main()':
a.cc:33:18: error: the value of 'k' is not usable in a constant expression
33 | bitset<k+1> dp;
| ^
a.cc:17:73: note: 'long long int k' is not const
17 | long long int n,cnt=0,ans=0,a[ohara],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,k;
| ^
a.cc:33:19: error: the value of 'k' is not usable in a constant expression
33 | bitset<k+1> dp;
| ^
a.cc:17:73: note: 'long long int k' is not const
17 | long long int n,cnt=0,ans=0,a[ohara],b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,k;
| ^
a.cc:33:17: note: in template argument for type 'long unsigned int'
33 | bitset<k+1> dp;
| ~^~
a.cc:34:11: error: invalid types 'int[int]' for array subscript
34 | dp[0]=true;
| ^
a.cc:42:16: error: invalid types 'int[long long int]' for array subscript
42 | if(dp[j]){
| ^
|
s384418335 | p03780 | C++ | #include<bits/stdc++.h>
using namespace std;
int main(){
int n,k;cin>>n>>k;
vector<long long int>a(n);
for(int i=0;i<n;i++) cin>>a.at(i);
sort(a.begin(),a.end());
long long int sum=0;
int t=-1;
for(int i=0;i<n;i++){
sum+=a.at(i);
if(sum>=k){
t=i;
break;
}
}
if(t==-1){
cout<<n<<endl;
}
else if(t==0){
cout<<n<<endl;
}
else{
int c=n;
for(int i=0;i<n;i++){
if(a.at(i)>=k){
c=i;
break;
}
}
long long int dp[c-t+1][k];
for(int i=0;i<c-t+1;i++){
for(int j=0;j<k;j++){
dp[i][j]=-1;
}
}
dp[0][0]=0;
int ret=0;
for(int i=0;i<c-t;i++){
for(int j=0;j<k;j++){
if(dp[i][j]>=0){
dp[i+1][j]=dp[i][j];
if(j+a.at(i+t)<k){
dp[i+1][j+a.at(i+t)]=dp[i][j]+a.at(i+t);
ret=max(dp[i+1][j+a.at(i+t)],ret);
}
}
}
}
int y;
for(int i=0;;i++){
if(a.at(i)>=k-ret){
y=i;
break;
}
}
cout<<y<<endl;
}
}
| a.cc: In function 'int main()':
a.cc:45:20: error: no matching function for call to 'max(long long int&, int&)'
45 | ret=max(dp[i+1][j+a.at(i+t)],ret);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
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:45:20: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
45 | ret=max(dp[i+1][j+a.at(i+t)],ret);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/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:45:20: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
45 | ret=max(dp[i+1][j+a.at(i+t)],ret);
| ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
|
s021643354 | p03780 | C++ | #include <bits/stdc++.h>
#define FOR(I,X,Y) for(int (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(int (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define INF 1000000007
#define LINF 1000000000000000007
typedef long long ll;
using namespace std;
int main(){
int N,K,ans=0;
cin >> N >> K;
int a[N];
FOR(i,0,N)cin >> a[i];
FOR(i,0,N){
if(a[i] < K){
boo flag = 0;
bool DP[K];
FOR(j,0,K)DP[j] = 0;
DP[0] = 1;
FOR(j,0,N){
if(i != j){
REP(k,0,K){
if(DP[k] && k+a[j] < K){
if(K-a[i] <= k+a[j] && k+a[j] < K){
flag = 1;
break;
}
else DP[k+a[j]] = 1;
}
}
}
if(flag)break;
}
if(flag)ans++;
}
}
cout << ans << endl;
}
| a.cc: In function 'int main()':
a.cc:17:7: error: 'boo' was not declared in this scope; did you mean 'bool'?
17 | boo flag = 0;
| ^~~
| bool
a.cc:26:17: error: 'flag' was not declared in this scope
26 | flag = 1;
| ^~~~
a.cc:33:12: error: 'flag' was not declared in this scope
33 | if(flag)break;
| ^~~~
a.cc:35:10: error: 'flag' was not declared in this scope
35 | if(flag)ans++;
| ^~~~
|
s588698186 | p03780 | C++ | #include <bits/stdc++.h>
using namespace std;
/* define const */
/* finish defineing const */
long n, k;
long cnt;
bool dp[5010][5010][5010] = {};
long a[5010];
vector<long> v;
void init_dp()
{
for (int i = 0; i < 5010; i++)
{
dp[i][0][0] = true;
}
}
void init_vector()
{
v.erase(v.begin(), v.end());
}
bool do_dpp(long idx, long x)
{
// int dp[5010][5010] = {};
// dp[0][0] = 1;
for (int i = 1; i <= n - 1; i++)
{
for (int j = 0; j <= 5000; j++)
{
dp[idx][i][j] |= dp[idx][i - 1][j];
if (j - v[i - 1] >= 0)
{
dp[idx][i][j] |= dp[idx][i - 1][j - v[i - 1]];
}
}
}
for (long i = k - x; i < k; i++)
{
if (i >= 0)
{
if (dp[idx][n - 1][i] == 1)
{
return 1;
}
}
}
return 0;
}
int main()
{
cin >> n >> k;
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
//input
cnt = n;
// dp用配列の初期化
init_dp();
sort(a, a + n, greater<long>());
for (int i = 0; i < n; i++)
{
cout << a[i] << " ";
}
cout << endl;
for (int i = 0; i < n; i++)
{
// vectorの初期化
// vector<long> v;
init_vector();
// i番目を除いてvectorに格納
for (int j = 0; j < n; j++)
{
if (i != j)
{
v.push_back(a[j]);
}
}
for (auto itr = v.begin(); itr != v.end(); ++itr)
{
cout << *itr << " ";
}
cout << endl;
// i番目を除いたvectorに対してdp
if (do_dpp(i, a[i]))
{
--cnt;
}
}
cout << cnt << endl;
}
| /tmp/cclcx8BR.o: in function `init_vector()':
a.cc:(.text+0x40): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cclcx8BR.o
a.cc:(.text+0x66): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cclcx8BR.o
a.cc:(.text+0x97): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cclcx8BR.o
/tmp/cclcx8BR.o: in function `do_dpp(long, long)':
a.cc:(.text+0x181): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cclcx8BR.o
a.cc:(.text+0x1c3): relocation truncated to fit: R_X86_64_PC32 against symbol `v' defined in .bss section in /tmp/cclcx8BR.o
/tmp/cclcx8BR.o: in function `main':
a.cc:(.text+0x35f): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/cclcx8BR.o
a.cc:(.text+0x3b3): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/cclcx8BR.o
a.cc:(.text+0x3c0): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/cclcx8BR.o
a.cc:(.text+0x3e5): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/cclcx8BR.o
a.cc:(.text+0x475): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/cclcx8BR.o
a.cc:(.text+0x482): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
|
s467434046 | p03780 | C++ | #include <iostream>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <list>
#include <math.h>
#include <map>
using namespace std;
#define REP(i, k, n) for(int i = k;i < n; i++)
#define rep(i, n) REP(i,0,n)
int dx[4] = {0,-1,1,0};
int dy[4] = {-1,0,0,1};
bool dp[5001][5001];
int tar = 0;
int N, K;
int a[5001];
void solve(int depth, int cost){
if(depth == N + 1)return;
if(dp[depth][cost])return;
dp[depth][cost] = true;
solve(depth+1, cost);
if((cost+a[depth] < K) && (tar != depth)){
solve(depth+1, cost+a[depth]);
}
}
int main(void){
cin >> N >> K;
for(int i = 0; i < N; i++){
cin >> a[i];
}
//dp[j枚目まで][総和をxにできるか]
sort(a, a+N);
int r = N;
int l = -1;
while(r - l > 1){
tar = (r+l) / 2;
if(a[tar]>K){
l=tar+1;continue;
}
fill_n(*dp, 5001*5001, false);
// solve(0, 0);
bool flag = false;
dp[0][0] = true;
rep(i,N)rep(j,K){
if(tar == i){
dp[i+1][j] = dp[i][j];
}else{
dp[i+1][j] = dp[i][j];
if(j-a[i] >= 0){
dp[i+1][j] |= dp[i][j-a[i]];
}
}
}
// cout << tar << ", " << a[tar] << endl;
// rep(i,K){
// cout << dp[N][i] << " ";
// }cout << endl;
REP(i,K-a[tar], K){
flag |= dp[N][i];
}//cout << (flag?"YES":"NO")<<endl;
if(!flag){
l = tar;
}else{
r = tar;
}
}
cout << l+1 << endl;
}
/*
20
19 10 9 1
*/
#include <iostream>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <list>
#include <math.h>
#include <map>
using namespace std;
#define REP(i, k, n) for(int i = k;i < n; i++)
#define rep(i, n) REP(i,0,n)
int dx[4] = {0,-1,1,0};
int dy[4] = {-1,0,0,1};
bool dp[5001][5001];
int tar = 0;
int N, K;
int a[5001];
void solve(int depth, int cost){
if(depth == N + 1)return;
if(dp[depth][cost])return;
dp[depth][cost] = true;
solve(depth+1, cost);
if((cost+a[depth] < K) && (tar != depth)){
solve(depth+1, cost+a[depth]);
}
}
int main(void){
cin >> N >> K;
for(int i = 0; i < N; i++){
cin >> a[i];
}
//dp[j枚目まで][総和をxにできるか]
sort(a, a+N);
int r = N;
int l = -1;
while(r - l > 1){
tar = (r+l) / 2;
if(a[tar]>K){
l=tar+1;continue;
}
fill_n(*dp, 5001*5001, false);
// solve(0, 0);
bool flag = false;
dp[0][0] = true;
rep(i,N)rep(j,K+1){
if(tar == i){
dp[i+1][j] = dp[i][j];
}else{
dp[i+1][j] = dp[i][j];
if(j-a[i] >= 0){
dp[i+1][j] |= dp[i][j-a[i]];
}
}
}
// cout << tar << ", " << a[tar] << endl;
// rep(i,K){
// cout << dp[N][i] << " ";
// }cout << endl;
REP(i,K-a[tar], K){
flag |= dp[N][i];
}//cout << (flag?"YES":"NO")<<endl;
if(!flag){
l = tar;
}else{
r = tar;
}
}
cout << r << endl;
}
/*
20
19 10 9 1
*/
| a.cc:87:5: error: redefinition of 'int dx [4]'
87 | int dx[4] = {0,-1,1,0};
| ^~
a.cc:12:5: note: 'int dx [4]' previously defined here
12 | int dx[4] = {0,-1,1,0};
| ^~
a.cc:88:5: error: redefinition of 'int dy [4]'
88 | int dy[4] = {-1,0,0,1};
| ^~
a.cc:13:5: note: 'int dy [4]' previously defined here
13 | int dy[4] = {-1,0,0,1};
| ^~
a.cc:89:6: error: redefinition of 'bool dp [5001][5001]'
89 | bool dp[5001][5001];
| ^~
a.cc:14:6: note: 'bool dp [5001][5001]' previously declared here
14 | bool dp[5001][5001];
| ^~
a.cc:90:5: error: redefinition of 'int tar'
90 | int tar = 0;
| ^~~
a.cc:15:5: note: 'int tar' previously defined here
15 | int tar = 0;
| ^~~
a.cc:91:5: error: redefinition of 'int N'
91 | int N, K;
| ^
a.cc:16:5: note: 'int N' previously declared here
16 | int N, K;
| ^
a.cc:91:8: error: redefinition of 'int K'
91 | int N, K;
| ^
a.cc:16:8: note: 'int K' previously declared here
16 | int N, K;
| ^
a.cc:92:5: error: redefinition of 'int a [5001]'
92 | int a[5001];
| ^
a.cc:17:5: note: 'int a [5001]' previously declared here
17 | int a[5001];
| ^
a.cc:93:6: error: redefinition of 'void solve(int, int)'
93 | void solve(int depth, int cost){
| ^~~~~
a.cc:18:6: note: 'void solve(int, int)' previously defined here
18 | void solve(int depth, int cost){
| ^~~~~
a.cc:104:5: error: redefinition of 'int main()'
104 | int main(void){
| ^~~~
a.cc:29:5: note: 'int main()' previously defined here
29 | int main(void){
| ^~~~
|
s469255730 | p03780 | C++ | #include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<ll,ll> P;
const ll MOD=1234567;
const ll INF=1000000010;
const ll LINF=1000000000000000010LL;
const int MAX=500010;
const double EPS=1e-3;
int dx[4]={0,1,0,1};
int dy[4]={0,0,1,1};
int main(){
int n,k;cin>>n>>k;
ll a[5010];for(int i=1;i<=n;i++)cin>>a[i];
sort(a+1,a+n+1);
int ng=0;int ok=n+1;
while(ok-ng>1){
bool dp[5010][5010]={false};
int mid=(ng+ok)/2;
ll s=a[mid];
a[mid]=0;
memset(dp,false,sizeof(dp));
dp[0][0]=true;
for(int i=1;i<=n;i++){
for(int j=0;j<=k;j++){
dp[i][j]|=dp[i-1][j];
if(j-a[i]>=0){
dp[i][j]|=dp[i-1][j-a[i]];
}
}
}
bool f=false;
for(int i=max(0,k-s);i<k;i++){
f|=dp[n][i];
}
if(f){
ok=mid;
}else{
ng=mid;
}
a[mid]=s;
}
cout<<ng<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:34:22: error: no matching function for call to 'max(int, ll)'
34 | for(int i=max(0,k-s);i<k;i++){
| ~~~^~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:34:22: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
34 | for(int i=max(0,k-s);i<k;i++){
| ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:34:22: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
34 | for(int i=max(0,k-s);i<k;i++){
| ~~~^~~~~~~
|
s177896041 | p03780 | C++ | v#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
int n,k,i,ans=0,a[5010];
cin>>n>>k;
for(i=0; i<n; i++)
scanf("%d",&a[i]);
sort(a,a+n);
ll sum=0;
for(i=n-1; i>=0; i--)
{
if(sum+a[i]<k) sum+=a[i];
else ans=i;
}
cout<<ans<<endl;
return 0;
}
| a.cc:1:2: error: stray '#' in program
1 | v#include <bits/stdc++.h>
| ^
a.cc:1:1: error: 'v' does not name a type
1 | v#include <bits/stdc++.h>
| ^
a.cc: In function 'int main()':
a.cc:7:5: error: 'cin' was not declared in this scope
7 | cin>>n>>k;
| ^~~
a.cc:9:9: error: 'scanf' was not declared in this scope
9 | scanf("%d",&a[i]);
| ^~~~~
a.cc:10:5: error: 'sort' was not declared in this scope; did you mean 'short'?
10 | sort(a,a+n);
| ^~~~
| short
a.cc:17:5: error: 'cout' was not declared in this scope
17 | cout<<ans<<endl;
| ^~~~
a.cc:17:16: error: 'endl' was not declared in this scope
17 | cout<<ans<<endl;
| ^~~~
|
s861370035 | p03780 | C++ | #include <bits/stdc++.h>
using namespace std;
int main()
{
int n,k,i,ans=0,a[5010];
cin>>n>>k;
for(i=0; i<n; i++)
scanf("%d",&a[i]);
sort(a,a+n);
ll sum=0;
for(i=n-1; i>=0; i--)
{
if(sum+a[i]<k) sum+=a[i];
else ans=i;
}
cout<<ans<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:10:5: error: 'll' was not declared in this scope
10 | ll sum=0;
| ^~
a.cc:13:12: error: 'sum' was not declared in this scope
13 | if(sum+a[i]<k) sum+=a[i];
| ^~~
|
s412669900 | p03780 | C++ | #include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int n, k;
bool need(int*, int);
int main(){
cin >> n >> k;
int a[n+1];
for(int i=1; i<=n; i++) cin >> a[i];
sort(a+1, a+n+1);
int l=1, r=n, m;
if(need(a, 1)){
cout << 0 << endl;
return 0;
}
if(!need(a, n)){
cout << n << endl;
return 0;
}
while(l+1<r){
m = (l+r)/2;
if(need(a, m)){
r = m;
}
else{
l = m;
}
}
cout << r-1 << endl;
return 0;
}
//カードindexが要るならtrue, いらないのならfalse
bool need(int* a, int index){
int tmp[n];
for(int i=1, j=1; i<=n; i++){
tmp[j] = a[i];
if(i!=index) j++;
}
bool dp[n][k];
for(int i=0; i<n; i++){
for(int j=0; j<k; j++) dp[i][j] = false;
}
dp[0][0] = true;
for(int i=1; i<n; i++){
for(int j=0; j<k; j++){
if(j<tmp[i]) dp[i][j] = dp[i-1][j];
else dp[i][j] = dp[i-1][j] || dp[i-1][j-tmp[i]];
}
}
for(int j=max(1LL*0, k-a[index]); j<k; j++){
if(dp[n-1][j]) return true;
}
return false;
}
| a.cc: In function 'bool need(int*, int)':
a.cc:62:16: error: no matching function for call to 'max(long long int, int)'
62 | for(int j=max(1LL*0, k-a[index]); j<k; j++){
| ~~~^~~~~~~~~~~~~~~~~~~
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:62:16: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
62 | for(int j=max(1LL*0, k-a[index]); j<k; j++){
| ~~~^~~~~~~~~~~~~~~~~~~
/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:2:
/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:62:16: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
62 | for(int j=max(1LL*0, k-a[index]); j<k; j++){
| ~~~^~~~~~~~~~~~~~~~~~~
|
s615760020 | p03780 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<ll> Vector;
typedef vector<Vector> DVector;
typedef priority_queue<PP, vector<PP>, greater<PP>> PPQueue;
#define fi first
#define se second
#define sfi se.fi
#define sse se.se
#define pb push_back
#define INF INT_MAX
#define MOD 1000000007
#define bcnt __builtin_popcount
#define all(x) (x).begin(),(x).end()
#define uni(x) x.erase(unique(all(x)),x.end())
#define ub(x,y) (upper_bound(all(x),y)-x.begin())
#define lb(x,y) (lower_bound(all(x),y)-x.begin())
#define rep(i,n) repl(i,0,n-1)
#define usort(x) sort(all(x))
#define dsort(x) sort(all(x),greater<ll>())
#define mkp(x,y) make_pair(x,y)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define exist(x,y) (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)
int main(){
cin.sync_with_stdio(false);
ll n,k;
cin >> n >> k;
Vector a(n);
rep(i,n)cin >> a[i];
dsort(a);
vector<bitset<5001>> table(n);
rep(i,n)table[i].set(i);
vector<bitset<5001>> dp(k,~bitset<5001>());
dp[0] = ~dp[0];
rep(i,n)for(ll j=k-1;j>=a[i];j--)if(!dp[j-a[i]][5000])dp[j] &= (dp[j-a[i]] | table[i]);
ll cou = n;
rep(i,n)repl(j,max(0,k-a[i]),k)if(!dp[j][i]){cou--;break;}
cout << cou << endl;
} | a.cc: In function 'int main()':
a.cc:49:21: error: no matching function for call to 'max(int, ll)'
49 | rep(i,n)repl(j,max(0,k-a[i]),k)if(!dp[j][i]){cou--;break;}
| ~~~^~~~~~~~~~
a.cc:34:35: note: in definition of macro 'repl'
34 | #define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)
| ^
In file included from /usr/include/c++/14/algorithm:60,
from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:49:21: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
49 | rep(i,n)repl(j,max(0,k-a[i]),k)if(!dp[j][i]){cou--;break;}
| ~~~^~~~~~~~~~
a.cc:34:35: note: in definition of macro 'repl'
34 | #define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)
| ^
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:49:21: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
49 | rep(i,n)repl(j,max(0,k-a[i]),k)if(!dp[j][i]){cou--;break;}
| ~~~^~~~~~~~~~
a.cc:34:35: note: in definition of macro 'repl'
34 | #define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)
| ^
|
s216803831 | p03780 | C++ | #include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE" ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible" ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible" ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j])
#define SCOUT(x) cout<<(x)<<" "
#define ENDL cout<<endl
#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i]
#define VECCOUT(x) for(auto tt=x.begin();tt!=x.end();tt++){if(tt!=x.begin())cout<<" ";cout<<(*tt);}cout<<endl
#define ALL(obj) (obj).begin(),(obj).end()
#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())
#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
cin>>head;
CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
template <class T = ll>
T IN(){T x;cin>>x;return (x);}
template <class Head>
void VT(Head head){}
template <class Head,class Seco,class... Tail>
void VT(Head&& head,Seco&& seco,Tail&&... tail){
seco.resize(head);
VT(head,move(tail)...);
}
void VT2(){}
template <class Head,class... Tail>
void VT2(Head&& head,Tail&&... tail){
VECCIN(head);
VT2(move(tail)...);
}
template <class Head>
void VT3(Head&& head){}
template <class Head,class Seco,class... Tail>
void VT3(Head&& head,Seco&& seco,Tail&&... tail){
seco[head]=IN();
VT3(head,move(tail)...);
}
#define VC1(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);VT2(__VA_ARGS__); //aaabbbccc
#define VC2(n,...) V __VA_ARGS__;VT(n,__VA_ARGS__);REP(i,n)VT3(i,__VA_ARGS__); //abcabcabc
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision; // cpp_int
#define P pair<int,int>
#define V vector<ll>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int,V,greater<int>>
#define str string
#define pb(a) push_back(a)
#define mp make_pair
int main(){
CIN(n,k);vector<ll> a(n);VECCIN(a);
cpp_int bs=0;bs |= ((cpp_int)1<<n+1);
vector<cpp_int> dp(k,bs);
vector<cpp_int> shifttable(n+2);
REP(i,n+2)shifttable[i] = ((cpp_int)1<<i);
// VECCOUT(shifttable);
dp[0] &= ~(shifttable[n+1]);
int cou=n;
REP(j,k){
if(!(dp[j] & (shifttable[n+1])))
REP(i,n)
if(!ans[i])
if(dp[j] & (shifttable[i]))
if(j + a[i] >= k){ans[i]=true;cou--;}
}
COUT(cou);
return 0;
}
| a.cc:74:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
74 | #include <boost/multiprecision/cpp_int.hpp>
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
|
s819976208 | p03780 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>
#include <functional>
#define INF 1000000000000000000
using namespace std;
typedef long long ll;
int n;
ll k;
ll a[5010];
bool dp[5010];
bool need(int m) {
for (int i = 1; i < k; i++) {
dp[i] = false;
}
dp[0] = true;
for (int i = 0; i < n; i++) {
if (i == m)continue;
for (int j = k - 1; j >= 0; j--) {
if (dp[j] && (j + a[i]) < k) {
dp[j + a[i]] = true;
}
}
}
for (int i = max(0, k - a[m]); i < k; i++) {
if (dp[i])return true;
}
return false;
}
int main(){
cin >> n>>k;
int lo, hi;
lo = 0; hi = n - 1;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n);
if (!need(n - 1)) {
cout << n << endl;
return 0;
}
while (lo != hi) {
int mid = (lo + hi) / 2;
if (need(mid)) {
hi = mid ;
}
else {
lo = mid + 1;
}
}
cout << lo << endl;
return 0;
}
| a.cc: In function 'bool need(int)':
a.cc:32:25: error: no matching function for call to 'max(int, ll)'
32 | for (int i = max(0, k - a[m]); i < k; i++) {
| ~~~^~~~~~~~~~~~~
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:32:25: note: deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
32 | for (int i = max(0, k - a[m]); i < k; i++) {
| ~~~^~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:2:
/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:25: note: mismatched types 'std::initializer_list<_Tp>' and 'int'
32 | for (int i = max(0, k - a[m]); i < k; i++) {
| ~~~^~~~~~~~~~~~~
|
s725076646 | p03780 | C++ | #include <cstdio>
#include <vector>
using namespace std;
int main() {
int n, k;
scanf("%d%d", &n, &k);
int ans = n, sum = 0;
vector<int> a(n);
for (int i = 0; i < n; i ++) scanf("%d", &a[i]);
sort(a.begin(), a.end());
for (int i = n - 1; i >= 0; i --) {
if (sum + a[i] < k) sum += a[i];
else ans = i;
}
printf("%d\n", ans);
return 0;
}
| a.cc: In function 'int main()':
a.cc:11:9: error: 'sort' was not declared in this scope; did you mean 'short'?
11 | sort(a.begin(), a.end());
| ^~~~
| short
|
s992315349 | p03780 | C++ | #include <iostream>
using namespace std;
int n,k,a[5000],ans=0,used[5001],sum;
int main(void){
cin>>n>>k;
for(int i=0;i<n;i++){
cin>>a[i];
sum+=a[i];
}
if(a[i]<k){
cout<<0<<endl;
return 0;
}
int s=a[0],j=1;
for(int i=0;j<n;s-=a[i],i++){
for(;j<n&&s<k;j++)s+=a[j];
for(int l=i;l<j;l++){
if(s-a[l]>=k&&!used[l]){
ans++;
used[l]=1;
}
}
}
cout<<ans<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:11:10: error: 'i' was not declared in this scope
11 | if(a[i]<k){
| ^
|
s717356410 | p03780 | C++ | #include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <chrono>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <sstream>
#include <queue>
using namespace std;
using ll = unsigned long long;
using triplet = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vi>;
int main()
{
#ifdef LOCAL_TEST
freopen("data.txt", "r", stdin);
#endif
int n, K;
scanf("%d %d\n", &n, &K);
vi cards(n);
for (int i = 0; i < n; ++i) scanf("%d", &cards[i]);
sort(cards.begin(), cards.end());
// if any sum of subset between [K-cards[i], K) exists that means this card is unnecessary
bitset<5002> sum;
sum[0] = 1;
int result = n;
bool bFound = false;
for (int j = n-1; j >= 0 && !bFound; --j)
{
int c = cards[j];
for (int i = K-c; i >= 0 && i < K; ++i)
{
if (sum[i])
{
result = j;
bFound = true;
break;
}
}
sum |= sum << c;
}
printf("%d\n", result);
return 0;
}
| a.cc: In function 'int main()':
a.cc:38:5: error: 'bitset' was not declared in this scope
38 | bitset<5002> sum;
| ^~~~~~
a.cc:15:1: note: 'std::bitset' is defined in header '<bitset>'; this is probably fixable by adding '#include <bitset>'
14 | #include <queue>
+++ |+#include <bitset>
15 |
a.cc:38:18: error: 'sum' was not declared in this scope
38 | bitset<5002> sum;
| ^~~
|
s605549947 | p03780 | C++ | #include "IntMod.h"
typedef IntMod<1000000007> MInt;
#include "Union_Find.h"
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
using namespace std;
#define REP(i,a,n) for(int i = a; i < (int)(n); ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFLL 0x3FFFFFFF3FFFFFFF
#define INFD 1.0e+308
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#if 1
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;
#endif
int N, K;
int A[100001];
bool DP[5000];
int main() {
cin >> N >> K;
REP(i, 0, N) {
cin >> A[i];
}
if (N > 400 || K > 400) {
cout << 1 << endl;
return 0;
}
int ans = 0;
REP(i, 0, N) {
fill(DP, DP + 401, false);
DP[0] = 1;
REP(j, 0, N) {
if (i == j) continue;
if (A[j] > K) continue;
REPM(k, K, 0) {
if (k - A[k] < 0) continue;
DP[k] |= DP[k - A[j]];
}
}
bool ok = true;
REP(s, K - A[i], K) {
if (DP[s]) ok = false;
}
if (ok) ++ans;
}
cout << ans << endl;
return 0;
}
| a.cc:1:10: fatal error: IntMod.h: No such file or directory
1 | #include "IntMod.h"
| ^~~~~~~~~~
compilation terminated.
|
s985552317 | p03780 | C++ |
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
typedef long long ll;
ll vs[5010];
bool needed[5010];
int N, K;
int memo[5010][5010];
int isPossible(int pos, int x) {
int& res = memo[pos][x];
if(res < 0) {
if (pos == N) {
res = x == 0;
} else {
res = isPossible(pos+1, x);
if(x-vs[pos] >= 0) {
res = res || isPossible(pos+1, x-vs[pos]);
}
}
}
return res;
}
int main(void) {
cin >> N >> K;
REP(i, N) {
cin >> vs[i];
}
sort(vs, vs + N);
memset(memo, -1, sizeof memo);
int res = N;
REP(i, N) {
if(i > 0 && vs[i] == vs[i-1]) {
needed[i] = needed[i-1];
} else {
for(int x = max(K-vs[i], 0); x < K; ++x) {
needed[i] = needed[i] || isPossible(i+1, x);
}
}
if(needed[i]) {
// cerr << " " << i << endl;
--res;
}
}
cout << res << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:43:22: error: no matching function for call to 'max(ll, int)'
43 | for(int x = max(K-vs[i], 0); x < K; ++x) {
| ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
257 | max(const _Tp& __a, const _Tp& __b)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: template argument deduction/substitution failed:
a.cc:43:22: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
43 | for(int x = max(K-vs[i], 0); x < K; ++x) {
| ~~~^~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
303 | max(const _Tp& __a, const _Tp& __b, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
from a.cc:5:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
5706 | max(initializer_list<_Tp> __l)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
5716 | max(initializer_list<_Tp> __l, _Compare __comp)
| ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: template argument deduction/substitution failed:
a.cc:43:22: note: mismatched types 'std::initializer_list<_Tp>' and 'long long int'
43 | for(int x = max(K-vs[i], 0); x < K; ++x) {
| ~~~^~~~~~~~~~~~
|
s668705513 | p03780 | C++ | #include<bits/stdc++.h>
using namespace std;
int N,K;
int ans = 0;
vector<int> V;
int dp[5010][10010] = {1};
int main()
{
scanf("%d%d",&N,&K);
for(int i = 0; i < N; i++)
{
int a;
scanf("%d",&a);
if(a <= K)
{
V.push_back(a);
}
}
N = V.size();
for(int i = 0; i < N; i++)
{
for(int j = 0; j <= K * 2; j++)
{
if(dp[i][j] != 0)
{
dp[i + 1][j] += dp[i][j];
if(i + V[i] <= K * 2)dp[i + 1][j + V[i]] += dp[i][j];
}
}
}
for(int i = 0; i < N; i++)
{
int now = V[i];
int mem[5010] = {0};
for(int j = 0; j <= K; j++)
{
if(j == K)ans++;
if(dp[N][j] - mem[j] > 0 && dp[N][j + now] > 0)
{
mem[j + now] += dp[N][j] - mem[j];
mem[j] += dp[N][j] - mem[j];
if(j >= K - now)
{
break;
}
}
}
}
printf("%d\n",ans);
}
| /tmp/cc44Qukr.s: Assembler messages:
/tmp/cc44Qukr.s: Fatal error: can't fill 256 bytes in section .data of /tmp/ccJOdwFz.o: 'No space left on device'
/tmp/cc44Qukr.s: Fatal error: /tmp/ccJOdwFz.o: No such file or directory
|
s986967951 | p03780 | 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 () {
int n, k;
cin >> n >> k;
vector<int> a(n);
ll sum = 0;
rep(i,n) {
cin >> a[i];
sum += a[i];
}
sort(a.begin(), a.end());
if(sum < k) {
cout << n << endl;
return 0;
}
vector<int> can(k,0);
can[0] = 1;
for(int i = n - 2; i >= 0; i--) {
for(int l = k - 1; l >= 0; l--) {
if(can[l] && l + a[i+1] < k) can[l+a[i+1]] = 1;
}
if((i != 0 && a[i] == a[i-1]) || k - a[i] <= 0) continue;
bool nec = false;
for(int j = k - a[i]; j < k; j++) {
if(can[j]) nec = true;
}
if(!nec) {
cout << i + 1 << endl;
return 0;
}
}
out << 0 << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:40:3: error: 'out' was not declared in this scope
40 | out << 0 << endl;
| ^~~
|
s517572956 | p03780 | C++ | #include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;
bool f(int pos, int k, vector<int> card)
{
const int prev = card[pos];
card[pos] = 0;
const int size = card.size();
vector<vector<bool>> table(size+1, vector<bool>(k+1, false));
table[0][0] = true;
for(int i=0; i<size; i++)
{
for(int j=0; j<k+1; j++)
{
if(table[i][j] == false)
continue;
table[i+1][j] = table[i][j];
int n = j + card[i];
if(n > k)
continue;
table[i+1][n] = true;
}
}
bool flag = false;
for(int i=max(0, k-prev); i<k; i++)
if(table[size][i] == true)
flag = true;
return flag;
}
int main(void)
{
int N, K;
cin >> N >> K;
vector<int> a(N);
for(int i=0; i<N; i++)
cin >> a[i];
vector<bool> cnt(N);
for(int i=0; i<N; i++)
cnt[i] = f(i, K, a);
cout << count(cnt.begin(), cnt.end(), false) << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:54:17: error: 'count' was not declared in this scope; did you mean 'cnt'?
54 | cout << count(cnt.begin(), cnt.end(), false) << endl;
| ^~~~~
| cnt
|
s864663054 | p03780 | C++ | #include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define all(v) begin(v), end(v)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000
#define int long long int
#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))
typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long ll;
typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
int const MOD = 1000000007;
ll mod_pow(ll x, ll n) {return (!n)?1:(mod_pow((x*x)%MOD,n/2)*((n&1)?x:1))%MOD;}
int madd(int a, int b) {return (a + b) % MOD;}
int msub(int a, int b) {return (a - b + MOD) % MOD;}
int mmul(int a, int b) {return (a * b) % MOD;}
int minv(int a) {return mod_pow(a, MOD-2);}
int mdiv(int a, int b) {return mmul(a, minv(b));}
namespace std {
bool operator<(const P& a, const P& b) {
return a.X != b.X ? a.X < b.X : a.Y < b.Y;
}
}
int N, K, a[5010];
bool dp[5010][5010];
// 必要ならば true
bool d(int x) {
if(a[x] > K) return true;
memset(dp, false, sizeof(dp));
dp[0][0] = true;
rep(i,0,N) repq(j,0,K) {
dp[i+1][j] |= dp[i][j];
if(i != x) dp[i+1][min(K, j+a[i])] |= dp[i][j];
}
bool ret = false;
rep(i,max(0LL, K-a[x]),K) {
ret |= dp[N][i];
}
return ret;
}
signed main() {
cin >> N >> K;
rep(i,0,N) cin >> a[i];
if(accumulate(a, a+N, 0LL) < K) {
cout << N << endl;
return 0;
}
sort(a, a+N);
int lb = 0, ub = N+1;
while(ub - lb > 1) {
int mid = (ub + lb) / 2;
if(d(mid)) ub = mid;
else lb = mid;
}
cout << ub << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:91:8: error: 'accumulate' was not declared in this scope
91 | if(accumulate(a, a+N, 0LL) < K) {
| ^~~~~~~~~~
|
s460663601 | p03780 | C++ | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll sum;
bool dp[5005][5005];
int N,K;
int a[5005];
int main() {
cin >> N >> K;
for(int i = 0; i < N; i++) {
cin >> a[i];
sum += a[i];
}
if(sum < K) {
cout << N <<endl; return 0;
}
sort(a,a+N,greater<int>());
int l = 0;
int r = N+1;
while(r - l > 1) {
for(int i = 0; i <= N; i++) fill(dp[i],dp[i]+N+1,false);
dp[0][0] = true;
int mid = (l+r) / 2;
if(a[mid] > K) {
l = mid
continue;
}
int tmp = a[mid];
a[mid] = 0;
for(int i = 0; i < N; i++) {
for(int j = K-1; j >= 0; j--) {
if(dp[i][j] && j + a[i] < 5005) {
dp[i+1][j+a[i]] = dp[i][j+a[i]] = dp[i][j];
dp[i+1][j] = dp[i][j];
}
}
}
a[mid] = tmp;
bool there = false;
for(int i = K - tmp; i < K; i++) {
if(dp[N][i]) {
there = true;
break;
}
}
if(there) l = mid;
else r = mid;
// cout <<r<<endl;
}
cout << N - r <<endl;
}
| a.cc: In function 'int main()':
a.cc:28:14: error: expected ';' before 'continue'
28 | l = mid
| ^
| ;
29 | continue;
| ~~~~~~~~
|
s003959238 | p03780 | C++ | #include <iostream>
#include <vector>
using namespace std;
int N, K, a[5000];
bool C(int idx) {
vector<vector<bool> > dp(N+1, vector<bool>(K+1, false));
dp[0][0] = true;
for(int i=0; i<N; i++) {
for(int j=0; j<=K; j++) {
if(dp[i][j]) {
dp[i+1][j] = true;
if(i != idx && j + a[i] <= K) dp[i+1][j+a[i]] = true;
}
}
}
for(int j=K-a[idx]; j<K; j++) {
if(dp[N][j]) return true;
}
return false;
}
int main() {
cin >> N >> K;
for(int i=0; i<N; i++) cin >> a[i];
sort(a, a+N, greater<int>());
int l = 0, h = N + 1;
while(h - l > 1) {
int m = (l + h) / 2;
if(C(m-1)) l = m;
else h = m;
}
cout << N - l << endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:27:5: error: 'sort' was not declared in this scope; did you mean 'short'?
27 | sort(a, a+N, greater<int>());
| ^~~~
| short
|
s900649700 | p03780 | Java | import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int K = sc.nextInt();
int[] a = new int[N];
for(int i = 0; i < N; i++) {
a[i] = sc.nextInt();
}
Arrays.sort(a);
int ans = -1;
int left = 0;
int right = N;
while(left < right) {
int med = (left + right) / 2;
if(a[med] < K) {
// dp[i][j]はカードiまででカードmedを使わずに総和をjと出来るかを表す
boolean[][] dp = new boolean[N][K];
dp[0][0] = true;
if(med != 0) dp[0][a[0]] = true;
for(int i = 1; i < N; i++) {
dp[i][0] = true;
for(int j = 1; j < K; j++) {
if(med != i) {
if(a[i] <= j) {
dp[i][j] = (dp[i - 1][j] == 1) || (dp[i - 1][j - a[i]] == 1);
} else {
dp[i][j] = dp[i - 1][j];
}
} else {
dp[i][j] = dp[i - 1][j];
}
}
}
boolean flg = false;
for(int j = K - a[med]; j < K; j++) {
if(dp[N - 1][j]) flg = true;
}
if(flg) {
right = med;
} else {
ans = med;
right = med + 1;
}
} else {
right = med;
}
}
ans++;
System.out.println(ans);
}
} | Main.java:28: error: incomparable types: boolean and int
dp[i][j] = (dp[i - 1][j] == 1) || (dp[i - 1][j - a[i]] == 1);
^
Main.java:28: error: incomparable types: boolean and int
dp[i][j] = (dp[i - 1][j] == 1) || (dp[i - 1][j - a[i]] == 1);
^
2 errors
|
s191565416 | p03780 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using vb = vector<bool>;
using vvb = vector<vb>;
int solve(long long N, long long K, vector<long long> &as);
int solve_core(long long K, vector<long long> &as);
void fill_dp(long long K, const vector<long long> &as, vvb & dp);
bool is_necessary(long long a, long long K, const vb &dpf, const vb &dpb);
int main() {
long long N, K;
cin >> N >> K;
vector<long long> as(N, 0);
for (auto & a : as) cin >> a;
cout << solve(N, K, as) << endl;
return 0;
}
int solve(long long N, long long K, vector<long long> &as){
if (N == 1) return (as[0] >= K) ? 0 : 1;
long long total = accumulate(as.begin(), as.end(), 0);
if (total < K) return N;
vector<long long> subset;
for (auto a : as) if (a < K) subset.push_back(a);
return solve_core(K, subset);
}
int solve_core(long long K, vector<long long> &as){
int N = as.size();
vector<vector<bool>> dpf(N + 1, vector<bool>(K, false)); // dpf[n][k] as[:n] の部分和を k にできるか否か
vector<vector<bool>> dpb(N + 1, vector<bool>(K, false)); // dpb[n][k] as[n:] の部分和を k にできるか否か
fill_dp(K, as, dpf);
reverse(as.begin(), as.end());
fill_dp(K, as, dpb);
reverse(dpb.begin(), dpb.end());
reverse(as.begin(), as.end());
int ans = 0;
for (int n = 0; n != N; ++n){
if (not is_necessary(as[n], K, dpf[n], dpb[n + 1])) ++ans;
}
return ans;
}
void fill_dp(long long K, const vector<long long> &as, vvb &dp){
// dp[n][k] as[:n] を用いて 部分和を k とできれば true できなければ false
int n = 0;
dp[0][0] = true;
for (const auto a : as){
++n;
dp[n] = dp[n - 1]; // 値がコピーされているのか?
for (auto k = K - 1; k >= a; --k){
if (dp[n - 1][k - a]) dp[n][k] = true;
}
}
}
bool is_necessary(long long a, long long K, const vb &dpf, const vb &dpb){
// a が必要であるかどうか判断する。
// dpf[k] as[:n] の部分和を k にできれば true, できなければ false
// dpb[k] as[n+1:] の部分和を k にできれば true, できなければ false
// 尺取り法の要領で、
// K > k1 + k2 >= K - a && dpf[k1] && dpf[k2] となる k1, k2 があれば true, なければ false を返す。
long long k2 = K - 1;
for (long long k1 = 0; k1 < K; ++k1){
if (not dpf[k1]) continue;
while (k1 + k2 >= K) --k2;
while (k2 >= 0 and k1 + k2 >= K - a) {
if (dpb[k2]) return true;
--k2;
}
}
return false;
}
| a.cc: In function 'int solve(long long int, long long int, std::vector<long long int>&)':
a.cc:25:23: error: 'accumulate' was not declared in this scope
25 | long long total = accumulate(as.begin(), as.end(), 0);
| ^~~~~~~~~~
|
s378684050 | p03780 | C++ | #include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define print(x) cout<<x<<endl;
int n, k;
int a[5002];
int ans;
bool is;
int main() {
cin >> n >> k;
rep(i, 0, n)cin >> a[i];
sort(a, a + n);
int l = 0, r = n;
while(r>l){
int s = (l + r) / 2;
if (a[s] > k)continue;
is = false;
bool dp[5002][5002] = {};
dp[0][0] = true;
if (s > 0)dp[0][a[0]] = true;
rep(i, 1, n) {
rep(j, 0, k) {
dp[i][j] = dp[i - 1][j] || dp[i-1][j - a[i]]];
}
}
rep (m, k - a[s], k) {
if (dp[n - 1][m]) { is = true; break; }
}
if (is)r = s;
else l = s + 1;
}
print(r);
} | a.cc: In function 'int main()':
a.cc:27:77: error: expected ';' before ']' token
27 | dp[i][j] = dp[i - 1][j] || dp[i-1][j - a[i]]];
| ^
| ;
|
s278148946 | p03780 | C++ | def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n,d=0) Array.new(n,d)end
def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.to_s.chomp.split(" ").map{|u|u.to_i}; return a end
def sum(a) ans = 0;a.each{|d|ans+=d} ;return ans end
n,k = inp
a =inp
dp = na2(k+1,2,0)
sum = sum(a)
sort = a.sort{|a,b| b<=>a}
if(sum < k)
puts n
exit
elsif(sum == k)
puts 0
exit
end
ans = Array.new(0,0)
c = 0
x = 0
h = {0 => 0}
dp[0][0] = 1
sort.each.with_index do |d,i|
ku = i %2
ti = (i+1)%2
(k+1).times do |dd|
if(dp[dd][ku] == 1)
dp[dd][ti] = 1
if(dd+d<k)
dp[dd + d][ti] = 1
else
ans = d
end
end
end
end
t = a.sort.index(ans).to_s.to_i
p (t ) | a.cc:5:28: error: too many decimal points in number
5 | def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
| ^~~~
a.cc:1:1: error: 'def' does not name a type
1 | def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
| ^~~
a.cc:6:29: error: 'a' does not name a type
6 | def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
| ^
a.cc:6:48: error: expected unqualified-id before 'return'
6 | def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
| ^~~~~~
a.cc:8:46: error: 'end' does not name a type
8 | def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end
| ^~~
a.cc:9:62: error: 'end' does not name a type
9 | def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
| ^~~
a.cc:11:56: error: expected unqualified-id before 'return'
11 | def inp() a=gets.to_s.chomp.split(" ").map{|u|u.to_i}; return a end
| ^~~~~~
a.cc:12:20: error: 'a' does not name a type
12 | def sum(a) ans = 0;a.each{|d|ans+=d} ;return ans end
| ^
a.cc:12:39: error: expected unqualified-id before 'return'
12 | def sum(a) ans = 0;a.each{|d|ans+=d} ;return ans end
| ^~~~~~
a.cc:18:1: error: expected unqualified-id before 'if'
18 | if(sum < k)
| ^~
a.cc:29:1: error: 'dp' does not name a type
29 | dp[0][0] = 1
| ^~
|
s341495800 | p03780 | C++ | #include <iostream>
#define lli long long int
#define DEBUG 0
using namespace std;
lli show(lli *a,lli num){
for(lli i=0;i<num;i++){
cout<<a[i]<<" ";
}
cout<<endl;
}
lli solve(lli *a,lli index,lli n,lli k){
lli dp[n+1][k];
for(lli i=0;i<=n;i++){
for(lli j=0;j<k;j++){
if(j==0){
dp[i][j]=1;
}else{
dp[i][j]=0;
}
}
}
for(lli i=0;i<n;i++){
for(lli j=0;j<k;j++){
if(dp[i][j]==1){
if(j+a[i]<k && i!=index){
dp[i+1][j+a[i]]=1;
}
dp[i+1][j]=1;
}
}
if(DEBUG)cout<<"index="<<index<<endl;
if(DEBUG)cout<<"i="<<i<<endl;
if(DEBUG)show(dp[i+1],k);
}
for(lli i=k-a[index];i<k;i++){
if(dp[n][i]==1){
return 1;
}
}
return 0;
}
lli main(){
lli n,k;
lli *a;
cin>>n>>k;
if(n>=5001||k>=5001){
return 0;
}
a = new lli[n];
for(lli i=0;i<n;i++){
cin>>a[i];
}
lli ans=n;
for(lli i=0;i<n;i++){
ans -= solve(a,i,n,k);
}
cout<<ans<<endl;
/*
if(ans!=0){
cout<<ans<<endl;
}
else{
cout<<n<<endl;
}
*/
return 0;
} | a.cc: In function 'long long int show(long long int*, long long int)':
a.cc:13:1: warning: no return statement in function returning non-void [-Wreturn-type]
13 | }
| ^
a.cc: At global scope:
a.cc:3:23: error: '::main' must return 'int'
3 | #define lli long long int
| ^~~
a.cc:52:1: note: in expansion of macro 'lli'
52 | lli main(){
| ^~~
|
s695537588 | p03780 | C++ | #include <iostream>
#define lli long long lli
#define DEBUG 0
using namespace std;
lli show(lli *a,lli num){
for(lli i=0;i<num;i++){
cout<<a[i]<<" ";
}
cout<<endl;
}
lli solve(lli *a,lli index,lli n,lli k){
lli dp[n+1][k];
for(lli i=0;i<=n;i++){
for(lli j=0;j<k;j++){
if(j==0){
dp[i][j]=1;
}else{
dp[i][j]=0;
}
}
}
for(lli i=0;i<n;i++){
for(lli j=0;j<k;j++){
if(dp[i][j]==1){
if(j+a[i]<k && i!=index){
dp[i+1][j+a[i]]=1;
}
dp[i+1][j]=1;
}
}
if(DEBUG)cout<<"index="<<index<<endl;
if(DEBUG)cout<<"i="<<i<<endl;
if(DEBUG)show(dp[i+1],k);
}
for(lli i=k-a[index];i<k;i++){
if(dp[n][i]==1){
return 1;
}
}
return 0;
}
lli main(){
lli n,k;
lli *a;
cin>>n>>k;
if(n>=5001||k>=5001){
return 0;
}
a = new lli[n];
for(lli i=0;i<n;i++){
cin>>a[i];
}
lli ans=n;
for(lli i=0;i<n;i++){
ans -= solve(a,i,n,k);
}
cout<<ans<<endl;
/*
if(ans!=0){
cout<<ans<<endl;
}
else{
cout<<n<<endl;
}
*/
return 0;
} | a.cc:8:5: error: expected initializer before 'show'
8 | lli show(lli *a,lli num){
| ^~~~
a.cc:15:5: error: expected initializer before 'solve'
15 | lli solve(lli *a,lli index,lli n,lli k){
| ^~~~~
a.cc:52:5: error: expected initializer before 'main'
52 | lli main(){
| ^~~~
|
s426220080 | p03780 | Java | import java.util.Scanner;
import java.util.Arrays;
public class Sub{
static int n, k;
static int[] a;
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
n = sc.nextInt();
k = sc.nextInt();
a = new int[n];
for(int i = 0; i < n; i++){
a[i] = sc.nextInt();
}
int count = 0;
for(int i = 0; i < n; i++){
if(a[i] >= k){
++count;
}
}
int[] b = new int[n - count];
int m = 0;
for(int i = 0; i < n; i++){
if(a[i] < k){
b[m++] = a[i];
}
}
int ans = 0;
for(int i = 0; i < m; i++){
if(!check(i, b)){
++ans;
}
}
System.out.println(ans);
}
private static boolean check(int index, int[] b){
int[] c = new int[b.length - 1];
int m = 0;
for(int i = 0; i < b.length; i++){
if(i != index){
c[m++] = b[i];
}
}
boolean[][] dp = new boolean[m + 1][400 * 400 + 1];
dp[0][0] = true;
for(int i = 1; i <= m; i++){
for(int j = 0; j < dp[i].length; j++){
if(j - c[i - 1] >= 0){
dp[i][j] = dp[i - 1][j] || dp[i - 1][j - c[i - 1]];
}
else{
dp[i][j] = dp[i - 1][j];
}
}
}
for(int s = k - b[index]; s < k; s++){
if(dp[m][s]){
return true;
}
}
return false;
}
} | Main.java:4: error: class Sub is public, should be declared in a file named Sub.java
public class Sub{
^
1 error
|
s087903191 | p03780 | C++ | #include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;
class NoNeed
{
private:
int n, k;
int sum;
vector<vector<bool> > l_dp;
vector<vector<bool> > r_dp;
vector<int> a;
public:
NoNeed(){
cin >> n >> k;
a.resize(n);
sum = 0;
for (int i = 0; i < n; ++i)
{
cin >> a[i];
sum += a[i];
}
l_dp = vector<vector<bool> >(n, vector<bool>(k+1, false));
r_dp = vector<vector<bool> >(n, vector<bool>(k+1, false));
}
bool is_valid(int med){
if(a[med] >= k){
return true;
}
for (int i = k - a[med]; i < k; ++i)
{
if(med == 0){
if(r_dp[1][i]) return true;;
break;
}
if(med == n-1){
if(l_dp[n-2][i]) return true;
break;
}
for (int j = 0; j <= i; ++j)
{
if(l_dp[med-1][j] && r_dp[med+1][i-j]){
return true;
}
}
}
return false;
}
void set_dp(){
l_dp[0][0] = true;
l_dp[0][a[0]] = true;
for (int i = 1; i < n; ++i)
{
for (int j = 0; j <= k; ++j)
{
if(l_dp[i-1][j] || (j - a[i] >= 0 && l_dp[i-1][j - a[i]]) ){
l_dp[i][j] = true;
}
}
}
r_dp[n-1][0] = true;
r_dp[n-1][a[n-1]] = true;
for (int i = n-2; i >= 0; --i)
{
for (int j = 0; j <= k; ++j)
{
if(r_dp[i+1][j] || (j - a[i] >= 0 && r_dp[i+1][j - a[i]]) ){
r_dp[i][j] = true;
}
}
}
}
void exec(){
sort(a.begin(), a.end());
if(sum < k){
cout << n << endl;
return;
}
if(n == 1){
cout << 0 << endl;
return;
}
set_dp();
int left = 0;
int right = n-1;
int ans = 0;
while(left < right){
int med = (left + right) / 2;
if(is_valid(med)){
right = med;
}else{
left = med + 1;
ans = left
}
}
cout << ans + 1 << endl;
}
};
int main(){
NoNeed nn = NoNeed();
nn.exec();
} | a.cc: In member function 'void NoNeed::exec()':
a.cc:106:25: error: expected ';' before '}' token
106 | }
| ^
|
s918653748 | p03780 | C++ | #include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <random>
#include <deque>
#define INF_LL 1e18
#define INF 1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const ll MOD = 1e9+7;
int dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
int dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
template<typename T>
void chmax(T &a, T &b){
a = max(a, b);
}
template<typename T>
void chmin(T &a, T &b){
a = min(a, b);
}
class Union_find{
private:
vector<int> par;
vector<int> rank;
int n;
public:
Union_find(int a){
n = a;
for(int i = 0;i < n;i++){
par.push_back(i);
rank.push_back(0);
}
}
int find(int x){
if(par[x] == x){
return x;
}else{
return par[x] = find(par[x]);
}
}
void unite(int x, int y){
x = find(x);
y = find(y);
if(x == y) return;
if(rank[x] < rank[y]){
par[x] = y;
}else{
par[y] = x;
if(rank[x] == rank[y]) rank[x]++;
}
}
bool same(int x, int y){
return find(x) == find(y);
}
};
class RMQ{
int n;
vector<int> dat;
public:
RMQ(int n_){
n = 1;
while(n < n_) n *= 2;
REP(i, n*2-1){
dat.push_back(INF);
}
}
void update(int x, int i){
i += n-1;
dat[i] = x;
while(i > 0){
i = (i-1)/2;
dat[i] = min(dat[i*2+1], dat[i*2+2]);
}
}
int query(int a, int b, int l, int r, int x){
if(a <= l && r <= b) return dat[x];
if(r <= a || b <= l) return INF;
int res = INF;
res = min(query(a, b, l, (l+r)/2, x*2+1), query(a, b, (l+r)/2, r, x*2+2));
return res;
}
int query(int a, int b){
return query(a, b, 0, n, 0);
}
};
const ll mod = 1e9+7;
int N, K;
vector<ll> a;
bool dp[5050][5050] = {};
bool ok(ll in){
memset(dp, 0, sizeof(dp));
dp[0][0] = true;
REP(i, N){
dp[i][0] = true;
REP(j, K+1) dp[i+1][j] = dp[i][j];
REP(j, K+1){
if(i != in){
if(dp[i][j]){
if(j+a[i] <= K)
//dp[i+1][j+a[i]] = true;
}
}
}
}
FOR(i, K-a[in], K){
if(dp[N][i]){
return true;
}
}
return false;
}
int main(void){
cin >> N >> K;
REP(i, N){
int A;
cin >> A;
a.push_back(A);
}
int l = 0, r = N, m;
sort(all(a));
while(r-l > 1){
m = (l+r)/2;
if(ok(m)){
r = m;
}else{
l = m;
}
}
if(!ok(m)){
cout << m+1 << endl;
}else{
cout << m << endl;
}
}
| a.cc: In function 'bool ok(ll)':
a.cc:138:33: error: expected primary-expression before '}' token
138 | }
| ^
|
s209750813 | p03780 | C++ | #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a)
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
ll dp[5050][5050];
int main(){
ll n,k,ans=0;
cin>>n>>k;
vector<ll>a(n);
//入力
rep(i,n)cin>>a[i];
sort(all(a));
rep(s,n){
memset(dp,0,sizeof(dp));
dp[0][0]=1;
rep(i,n+1){
rep(j,k+1){
dp[i+1][j]+=dp[i][j];
if(j+a[i]<=k&&i!=s){
dp[i+1][j+a[i]]+=dp[i][j];
}
}
}
FOR(j,max(k-a[s],0ll),k){
if(dp[n+1][j]){
ans++;
break;
}
}
}
cout<<n-ans<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:40:17: error: 'memset' was not declared in this scope
40 | memset(dp,0,sizeof(dp));
| ^~~~~~
a.cc:11:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
10 | #include <queue>
+++ |+#include <cstring>
11 | #include <time.h>
|
s801924466 | p03780 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a)
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
ll dp[5050][5050];
int main(){
ll n,k,ans=0;
cin>>n>>k;
vector<ll>a(n);
//入力
rep(i,n)cin>>a[i];
sort(all(a));
rep(s,n){
memset(dp,0,sizeof(dp));
dp[0][0]=1;
rep(i,n+1){
rep(j,k+1){
dp[i+1][j]+=dp[i][j];
if(j+a[i]<=k&&i!=s){
dp[i+1][j+a[i]]+=dp[i][j];
}
}
}
FOR(j,max(k-a[s],0ll),k){
if(dp[n+1][j]){
ans++;
break;
}
}
}
cout<<n-ans<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:39:17: error: 'memset' was not declared in this scope
39 | memset(dp,0,sizeof(dp));
| ^~~~~~
a.cc:10:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
9 | #include <queue>
+++ |+#include <cstring>
10 | #include <time.h>
|
s584394692 | p03780 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>
using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a)
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
ll dp[5050][5050];
int main(){
ll n,k,ans=0;
cin>>n>>k;
vector<ll>a(n);
//入力
rep(i,n)cin>>a[i];
sort(all(a));
rep(s,n){
memset(dp,0,sizeof(dp));
dp[0][0]=1;
rep(i,n+1){
rep(j,k+1){
dp[i+1][j]+=dp[i][j];
if(j+a[i]<=k&&i!=s){
dp[i+1][j+a[i]]+=dp[i][j];
}
}
}
FOR(j,k-a[s],k){
if(dp[n+1][j]){
ans++;
break;
}
}
}
cout<<n-ans<<endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:39:17: error: 'memset' was not declared in this scope
39 | memset(dp,0,sizeof(dp));
| ^~~~~~
a.cc:10:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
9 | #include <queue>
+++ |+#include <cstring>
10 | #include <time.h>
|
s980330325 | p03780 | C++ | #include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; --i)
typedef long long ll;
typedef long double ld;
using namespace std;
void solve(ll N, ll K, vector<ll> a){
ll ans = 0;
vector<ll> dp(K + 1);
dp[0] = 1;
rep(i, N) {
rep(j, N) {
if (i == j) continue;
rep(k, a[j]) {
if (K - k - 1 >= 0) dp[K] += dp[K - k - 1];
}
rrep(k, K) {
if (k - a[j] >= 0) dp[k] = dp[k] + dp[k - a[j]];
}
}
ll hoge = 0;
rep(k, a[i]) {
if (K - k - 1 >= 0) hoge += dp[K - k - 1];
}
if (hoge == 0) ans++;
fill(dp.begin(), dp.end(), 0);
dp[0] = 1;
}
cout << ans << endl;
}
int main(){
// 提出時は削除 //////////////////////////////
FILE* fp_in = //freopen("/Users/kokinakamura/git/ToolsForAtCoder/workspace/abc056/D/in_D_3.txt", "r", stdin);
////////////////////////////////////////////
ll N;
ll K;
scanf("%lld",&N);
vector<ll> a(N-1+1);
scanf("%lld",&K);
for(int i = 0 ; i <= N-1 ; i++){
scanf("%lld",&a[i]);
}
solve(N, K, a);
// 提出時は削除 //////////////////////////////
// fclose(fp_in);
////////////////////////////////////////////
return 0;
}
| a.cc: In function 'int main()':
a.cc:41:12: error: expected primary-expression before 'N'
41 | ll N;
| ^
a.cc:43:23: error: 'N' was not declared in this scope
43 | scanf("%lld",&N);
| ^
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.