Search is not available for this dataset
name stringlengths 2 112 | description stringlengths 29 13k | source int64 1 7 | difficulty int64 0 25 | solution stringlengths 7 983k | language stringclasses 4
values |
|---|---|---|---|---|---|
p01899 Yamanote-line Game | B: Yamanote-line Game-Yamanote-line Game-
Bean (?) Knowledge
The Yamanote line is convenient. The reason is that you can ride as many laps as time allows just by paying 130 yen. However, if you board with a ticket, you must be careful about the valid time of the ticket. It seems safe with an IC card. Taking advantage... | 7 | 0 | #include<iostream>
using namespace std;
int main(){
int N,d,p[1000],count=0;
cin >> N >> d;
for(int i=0;i<N;i++){
cin >> p[i];
if(p[i] > d){
count = count + (p[i]-d);
}
}
if(count == 0){
cout << "kusoge\n";
}
else{
cout << count << "\n";
}
return 0;
} | CPP |
p01899 Yamanote-line Game | B: Yamanote-line Game-Yamanote-line Game-
Bean (?) Knowledge
The Yamanote line is convenient. The reason is that you can ride as many laps as time allows just by paying 130 yen. However, if you board with a ticket, you must be careful about the valid time of the ticket. It seems safe with an IC card. Taking advantage... | 7 | 0 | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.Closeable;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
... | JAVA |
p01899 Yamanote-line Game | B: Yamanote-line Game-Yamanote-line Game-
Bean (?) Knowledge
The Yamanote line is convenient. The reason is that you can ride as many laps as time allows just by paying 130 yen. However, if you board with a ticket, you must be careful about the valid time of the ticket. It seems safe with an IC card. Taking advantage... | 7 | 0 | #include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
int n,m,ans=0,x;
cin>>n>>m;
r(i,n){
cin>>x;
if(x>m)ans+=x-m;
}
if(!ans)cout<<"kusoge"<<endl;
else cout<<ans<<endl;
} | CPP |
p01899 Yamanote-line Game | B: Yamanote-line Game-Yamanote-line Game-
Bean (?) Knowledge
The Yamanote line is convenient. The reason is that you can ride as many laps as time allows just by paying 130 yen. However, if you board with a ticket, you must be careful about the valid time of the ticket. It seems safe with an IC card. Taking advantage... | 7 | 0 | #include<bits/stdc++.h>
using namespace std;
int main(){
int N,d,p[1000]={},f=0,ans=0;
cin>>N>>d;
for(int i=0;i<N;i++)cin>>p[i];
for(int i=0;i<N;i++)
if(p[i]>d){
if(f==0)f=1;
ans+=p[i]-d;
}
if(f==1)cout<<ans<<endl;
else cout<<"kusoge"<<endl;
return 0;
} | CPP |
p01899 Yamanote-line Game | B: Yamanote-line Game-Yamanote-line Game-
Bean (?) Knowledge
The Yamanote line is convenient. The reason is that you can ride as many laps as time allows just by paying 130 yen. However, if you board with a ticket, you must be careful about the valid time of the ticket. It seems safe with an IC card. Taking advantage... | 7 | 0 | #define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include... | CPP |
p01899 Yamanote-line Game | B: Yamanote-line Game-Yamanote-line Game-
Bean (?) Knowledge
The Yamanote line is convenient. The reason is that you can ride as many laps as time allows just by paying 130 yen. However, if you board with a ticket, you must be careful about the valid time of the ticket. It seems safe with an IC card. Taking advantage... | 7 | 0 | #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <cassert>
typedef long long ll;
using namespace std;
#define debug(x) c... | CPP |
p01899 Yamanote-line Game | B: Yamanote-line Game-Yamanote-line Game-
Bean (?) Knowledge
The Yamanote line is convenient. The reason is that you can ride as many laps as time allows just by paying 130 yen. However, if you board with a ticket, you must be careful about the valid time of the ticket. It seems safe with an IC card. Taking advantage... | 7 | 0 | #include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using names... | CPP |
p01899 Yamanote-line Game | B: Yamanote-line Game-Yamanote-line Game-
Bean (?) Knowledge
The Yamanote line is convenient. The reason is that you can ride as many laps as time allows just by paying 130 yen. However, if you board with a ticket, you must be careful about the valid time of the ticket. It seems safe with an IC card. Taking advantage... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
int main()
{
int N, d;
cin >> N >> d;
int p[1001];
for(int i = 0; i < N; i++) cin >> p[i];
sort(p, p + N);
reverse(p, p + N);
int ans = -d + p[0];
for(int i = 1; i < N; i++) {
if(ans < ans + p[i] - d) ans += p[i] - d;
else break;
}
if(ans <= 0)... | CPP |
p01899 Yamanote-line Game | B: Yamanote-line Game-Yamanote-line Game-
Bean (?) Knowledge
The Yamanote line is convenient. The reason is that you can ride as many laps as time allows just by paying 130 yen. However, if you board with a ticket, you must be careful about the valid time of the ticket. It seems safe with an IC card. Taking advantage... | 7 | 0 | #include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
int n,d;
cin>>n>>d;
vector<int> p(n);
for(int i=0;i<n;i++) cin>>p[i];
int ans=0;
for(int i=0;i<n;i++) ans+=max(0,p[i]-d);
if(ans) cout<<ans<<endl;
else cout<<"kusoge"<<endl;
return 0;
}
| CPP |
p01899 Yamanote-line Game | B: Yamanote-line Game-Yamanote-line Game-
Bean (?) Knowledge
The Yamanote line is convenient. The reason is that you can ride as many laps as time allows just by paying 130 yen. However, if you board with a ticket, you must be careful about the valid time of the ticket. It seems safe with an IC card. Taking advantage... | 7 | 0 | #include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
signed main(){
int n, d, a;
cin >> n >> d;
int ans = 0;
rep(i, 0, n){
cin >> a;
if(a > ... | CPP |
p01899 Yamanote-line Game | B: Yamanote-line Game-Yamanote-line Game-
Bean (?) Knowledge
The Yamanote line is convenient. The reason is that you can ride as many laps as time allows just by paying 130 yen. However, if you board with a ticket, you must be careful about the valid time of the ticket. It seems safe with an IC card. Taking advantage... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll mod=INF;
int main() {
int n,d;
cin >>... | CPP |
p01899 Yamanote-line Game | B: Yamanote-line Game-Yamanote-line Game-
Bean (?) Knowledge
The Yamanote line is convenient. The reason is that you can ride as many laps as time allows just by paying 130 yen. However, if you board with a ticket, you must be careful about the valid time of the ticket. It seems safe with an IC card. Taking advantage... | 7 | 0 | #include <iostream>
int main()
{
int N, d;
std::cin >> N >> d;
int p, res = 0;
for (int i = 0; i < N; i++) {
std::cin >> p;
res += std::max(0, p - d);
}
if (res == 0) {
std::cout << "kusoge" << std::endl;
} else {
std::cout << res << std::endl;
}
... | CPP |
p01899 Yamanote-line Game | B: Yamanote-line Game-Yamanote-line Game-
Bean (?) Knowledge
The Yamanote line is convenient. The reason is that you can ride as many laps as time allows just by paying 130 yen. However, if you board with a ticket, you must be careful about the valid time of the ticket. It seems safe with an IC card. Taking advantage... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
int main(void){
int N,d;
cin>>N>>d;
vector<int> p(N);
rep(i,N)cin>>p[i];
int res=0;
rep(i,N){
res+=max(0,p[i]-d);
}
if(res==0)cout<<"kusoge"<<endl;
else cout<<res<<endl;
return 0;
} | CPP |
p01899 Yamanote-line Game | B: Yamanote-line Game-Yamanote-line Game-
Bean (?) Knowledge
The Yamanote line is convenient. The reason is that you can ride as many laps as time allows just by paying 130 yen. However, if you board with a ticket, you must be careful about the valid time of the ticket. It seems safe with an IC card. Taking advantage... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se... | CPP |
p01899 Yamanote-line Game | B: Yamanote-line Game-Yamanote-line Game-
Bean (?) Knowledge
The Yamanote line is convenient. The reason is that you can ride as many laps as time allows just by paying 130 yen. However, if you board with a ticket, you must be careful about the valid time of the ticket. It seems safe with an IC card. Taking advantage... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
int main() {
int n, d, ans = 0;
cin >> n >> d;
REP(i,n){
int p;
cin >> p;
ans += max(0, p-d);
}
if(ans > 0){
cout << ans << endl;
}
else {
cout << "kusoge" <<... | CPP |
p01899 Yamanote-line Game | B: Yamanote-line Game-Yamanote-line Game-
Bean (?) Knowledge
The Yamanote line is convenient. The reason is that you can ride as many laps as time allows just by paying 130 yen. However, if you board with a ticket, you must be careful about the valid time of the ticket. It seems safe with an IC card. Taking advantage... | 7 | 0 | #include<bits/stdc++.h>
using namespace std;
int main(){
int n,d,p[1010];
cin>>n>>d;
for(int i=0;i<n;i++)cin>>p[i];
sort(p,p+n);
int ans=0;
for(int i=0;i<n;i++){
if(p[n-1-i]<=d)break;
ans+=p[n-1-i]-d;
}
if(ans)cout<<ans<<endl;
else cout<<"kusoge"<<endl;
return 0;
}
| CPP |
p01899 Yamanote-line Game | B: Yamanote-line Game-Yamanote-line Game-
Bean (?) Knowledge
The Yamanote line is convenient. The reason is that you can ride as many laps as time allows just by paying 130 yen. However, if you board with a ticket, you must be careful about the valid time of the ticket. It seems safe with an IC card. Taking advantage... | 7 | 0 | #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#define LP(i,n) for(int i=0;i<n;i++)
#define Mset(x,v) memset(x,v,sizeof(x))
#define ... | CPP |
p01899 Yamanote-line Game | B: Yamanote-line Game-Yamanote-line Game-
Bean (?) Knowledge
The Yamanote line is convenient. The reason is that you can ride as many laps as time allows just by paying 130 yen. However, if you board with a ticket, you must be careful about the valid time of the ticket. It seems safe with an IC card. Taking advantage... | 7 | 0 | #include <iostream>
using namespace std;
int main(void){
int n,m,a,sum=0;
cin>>n>>m;
for(int i=0;i<n;i++){
cin>>a;
if(a>m)sum+=a-m;
}
if(sum<1)cout<<"kusoge"<<endl;
else cout<<sum<<endl;
return 0;
} | CPP |
p01899 Yamanote-line Game | B: Yamanote-line Game-Yamanote-line Game-
Bean (?) Knowledge
The Yamanote line is convenient. The reason is that you can ride as many laps as time allows just by paying 130 yen. However, if you board with a ticket, you must be careful about the valid time of the ticket. It seems safe with an IC card. Taking advantage... | 7 | 0 | #include <iostream>
#include <algorithm>
using namespace std;
int n, p;
signed main() {
cin >> n >> p;
int ans = 0;
for (int i = 0; i < n; i++) {
int k; cin >> k;
ans += max(0, k - p);
}
if (!ans)cout << "kusoge\n";
else cout << ans << endl;
}
| CPP |
p01899 Yamanote-line Game | B: Yamanote-line Game-Yamanote-line Game-
Bean (?) Knowledge
The Yamanote line is convenient. The reason is that you can ride as many laps as time allows just by paying 130 yen. However, if you board with a ticket, you must be careful about the valid time of the ticket. It seems safe with an IC card. Taking advantage... | 7 | 0 | #include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n... | CPP |
p01899 Yamanote-line Game | B: Yamanote-line Game-Yamanote-line Game-
Bean (?) Knowledge
The Yamanote line is convenient. The reason is that you can ride as many laps as time allows just by paying 130 yen. However, if you board with a ticket, you must be careful about the valid time of the ticket. It seems safe with an IC card. Taking advantage... | 7 | 0 | #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)
int main(){
int n,d;
cin>>n>>d;
vector<int> v(n);
rep(i,n)cin>>v[i];
i... | CPP |
p01899 Yamanote-line Game | B: Yamanote-line Game-Yamanote-line Game-
Bean (?) Knowledge
The Yamanote line is convenient. The reason is that you can ride as many laps as time allows just by paying 130 yen. However, if you board with a ticket, you must be careful about the valid time of the ticket. It seems safe with an IC card. Taking advantage... | 7 | 0 | import java.util.*;
public class Main {
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int d = sc.nextInt();
long total = 0;
for (int i = 0; i < n; i++) {
int x = sc.nextInt();
if (x >= d) {
total += x - d;
}
}
if (total <... | JAVA |
p02036 Donuts Orientation | G: Donuts Orientation
story
Homu-chan's recent boom is making sweets. It seems that he makes a lot of sweets and shares them with his friends. Homu-chan seems to be trying to make donuts this time.
There are many important things in making donuts. Not only the dough and seasoning, but also the decorations to make it... | 7 | 0 | #include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd... | CPP |
p02036 Donuts Orientation | G: Donuts Orientation
story
Homu-chan's recent boom is making sweets. It seems that he makes a lot of sweets and shares them with his friends. Homu-chan seems to be trying to make donuts this time.
There are many important things in making donuts. Not only the dough and seasoning, but also the decorations to make it... | 7 | 0 | #include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)... | CPP |
p02036 Donuts Orientation | G: Donuts Orientation
story
Homu-chan's recent boom is making sweets. It seems that he makes a lot of sweets and shares them with his friends. Homu-chan seems to be trying to make donuts this time.
There are many important things in making donuts. Not only the dough and seasoning, but also the decorations to make it... | 7 | 0 | #include "bits/stdc++.h"
#include<vector>
#include<iostream>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<iomanip>
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<stack>
#include<complex>
#pragma warning(disable:4996)
using namespace std;
using ld... | CPP |
p02036 Donuts Orientation | G: Donuts Orientation
story
Homu-chan's recent boom is making sweets. It seems that he makes a lot of sweets and shares them with his friends. Homu-chan seems to be trying to make donuts this time.
There are many important things in making donuts. Not only the dough and seasoning, but also the decorations to make it... | 7 | 0 | #include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#includ... | CPP |
p02036 Donuts Orientation | G: Donuts Orientation
story
Homu-chan's recent boom is making sweets. It seems that he makes a lot of sweets and shares them with his friends. Homu-chan seems to be trying to make donuts this time.
There are many important things in making donuts. Not only the dough and seasoning, but also the decorations to make it... | 7 | 0 | #include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
Int MOD;
template<typename T>
struct Mint{
T v;
Mint():v(0){}
Mint(signed v):v(v){}
Min... | CPP |
p02036 Donuts Orientation | G: Donuts Orientation
story
Homu-chan's recent boom is making sweets. It seems that he makes a lot of sweets and shares them with his friends. Homu-chan seems to be trying to make donuts this time.
There are many important things in making donuts. Not only the dough and seasoning, but also the decorations to make it... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i... | CPP |
p02036 Donuts Orientation | G: Donuts Orientation
story
Homu-chan's recent boom is making sweets. It seems that he makes a lot of sweets and shares them with his friends. Homu-chan seems to be trying to make donuts this time.
There are many important things in making donuts. Not only the dough and seasoning, but also the decorations to make it... | 7 | 0 | #include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
usi... | CPP |
p02036 Donuts Orientation | G: Donuts Orientation
story
Homu-chan's recent boom is making sweets. It seems that he makes a lot of sweets and shares them with his friends. Homu-chan seems to be trying to make donuts this time.
There are many important things in making donuts. Not only the dough and seasoning, but also the decorations to make it... | 7 | 0 | // vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<l_l, l_l> llll;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
if(a < b) {
a = b;
return true;
}
return false;
}
template<class T>
inline bool chmin(T &a,... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int N;
long long dp[2][2020];
vector<pair<pair<long long,long long>,pair<long long,long long> > >E;
int main()
{
cin>>N;
for(int i=0;i<=2000;i++)dp[0][i]=-1e18;
for(int i=0;i<N;i++)
{
long long R,A,W,T;
cin>>R>>A>>W>>T;
T--;
E.push... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
const int INF = 1e8;
int main(){
int n;
cin>>n;
vector<int> r(n), a(n), w(n), t(n);
for( int i=0; i<n; ++i ){
cin>>r[i]>>a[i]>>w[i]>>t[i];
}
for( int i=0; i<n; ++i ){
int idx =... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
const int inf=1e9;
struct data {
int r,a,w,t;
};
bool asc(const data &l,const data &r) {
return l.t+l.r>r.t+r.r;
}
int n;
vector<data> v;
int dp[2005][4005][2]={0};//dp[i][j][k][l]:i個目まで歌って容量がjでkのboolは歌ってるかどうか
//これだとそこのスタートのそれがそうなので無理
void chmax(int &a,int b){
a=max... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <s... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll ... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#defi... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;
#define SIZE 2005
enum Type{
NOT,
USED,
};
struct Info{
bool operator<(const struct Info &arg) c... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#in... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//INSERT ABOVE HERE
signed main(){
Int n;
cin>>n;
vector<Int> rs(n),as(n),ws(n),ts(n);
... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;
template<typename T,typename U>istream & operator >> (istr... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll ... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
using namespace std;
typedef ... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #include <iostream>
#include <string>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#define llint long long
#define inf 1000000000000000000
using namespace std;
llint n;
llint dp[2005][4005][2];
llint r[2005], a[2005], w[2005], t[2005];
llint order[2005];
bool comp(llint i, llint j)
{
return r[i]+t[i] ... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #include<bits/stdc++.h>
using namespace std;
#define N 2000
int r[N], a[N], w[N], t[N];
int dp[N+1][N+1][2];
int main(){
int n;
cin >> n;
for(int i = 0; i < n; i++){
cin >> r[i] >> a[i] >> w[i] >> t[i];
}
vector<int> order(n);
iota(order.begin(), order.end(), 0);
sort(order.begin(),order.end(),[... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #include <bits/stdc++.h>
#define INF 1e+18
#define int long long
using namespace std;
template<class T> T &chmin(T &a,const T &b) { return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b) { return a = max(a,b); }
struct song{
int r,a,w,t;
};
int dp[2010][4050][2] = {};
signed main(){
int n;
cin >> n;
... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
int main() {
cin.tie(nullptr); ios::sync_with_stdio(false);
int n; cin >> n;
V<> r(n), a(n), w(n), t(n); for (int i = 0; i < n; ++i) cin >> r[i] >> a[i]... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #include <bits/stdc++.h>
#define inf (long long)(1e9)
using namespace std;
struct data {
long long r, a, w, t;
};
bool asc(const data &l, const data &r) {
return l.t + l.r > r.t + r.r;
}
long long n;
vector<data> v;
long long dp[2005][4005][2] = {0};
long long solve();
int main() {
cin >> n;
v.resize(n);
... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
struct K {
int R, A, W, T;
bool operator<(const K &right)const {
return ... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int INF = INT_MAX;
void chmax(ll &a, ll b){
a = max(a, b);
}
ll dp[2005][4005][2];
int main(){
int n;
cin >> n;
vector<P> ls;
vector<int> id(n), r(n), a(n), w(n), t(n);
for(int i=0;i<n;i+... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
template<typename A,typename B>inline ... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef pair<int,int> pii;
#define INF 1e9
struct data{
int r,a,w,t;
bool operator<(const data &another) const
{
return r+t < another.r + another.t;
};
};
... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec sec... | CPP |
p02179 Monster Buster | problem
AOR Ika is a monster buster.
One day, as I was walking down the road, I met a sleeping monster.
AOR Ika, who has a strong fighting spirit, decides to hit the monster with a wake-up blow. However, the current attack power of AOR Ika is $ 0 $, and she cannot make a decent attack as it is.
AOR Ika-chan, who is ... | 7 | 0 | #include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,... | CPP |
p02322 Knapsack Problem with Limitations II | You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most $W$, that is capacity of the knapsack.
* You ... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#defin... | CPP |
p02322 Knapsack Problem with Limitations II | You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most $W$, that is capacity of the knapsack.
* You ... | 7 | 0 | #include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
//INSERT ABOVE HERE
signed main(){
Int n,l;
cin>>n>>l;
vector<Int> v(n),w(n),m(n);
for... | CPP |
p02322 Knapsack Problem with Limitations II | You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most $W$, that is capacity of the knapsack.
* You ... | 7 | 0 | import sys
from collections import deque
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
N, W = map(int, readline().split())
vs = [0]*N; ws = [0]*N; ms = [0]*N
for i in range(N):
vs[i], ws[i], ms[i] = map(int, readline().split())
V0 = max(vs)
V = sum(v * min(V0, m) for ... | PYTHON3 |
p02322 Knapsack Problem with Limitations II | You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most $W$, that is capacity of the knapsack.
* You ... | 7 | 0 | #include<bits/stdc++.h>//c++14
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf = 1e15;
ll x = 25;
ll N,W;
vector<ll> dp,v,w,m;
ll solve(){//O(NWlogm)
vector<ll> dp(N*x*50+1,inf);
dp[0] = 0;
for(ll i=0;i<N;i++){
ll num = min(m[i],x) ;
m[i] -= num;
for(ll j=1;num > 0; j<<=1 ... | CPP |
p02322 Knapsack Problem with Limitations II | You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most $W$, that is capacity of the knapsack.
* You ... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct Item {
ll v, w, m;
Item(){}
explicit Item(ll v, ll w, ll m):v(v), w(w), m(m){}
bool operator < (const Item& item) const {
return v*item.w < item.v*w;
}
};
constexpr ll MAX_N = 50;
constexpr ll MAX_V = 50;
constexpr ll LIMIT = M... | CPP |
p02322 Knapsack Problem with Limitations II | You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most $W$, that is capacity of the knapsack.
* You ... | 7 | 0 | // includes
#include <bits/stdc++.h>
// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin... | CPP |
p02322 Knapsack Problem with Limitations II | You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most $W$, that is capacity of the knapsack.
* You ... | 7 | 0 | #include <iostream>
#include <limits>
#include <vector>
#include <algorithm>
using ll = long long;
const ll INF = std::numeric_limits<ll>::max() / 2;
const ll VMAX = 50;
const ll NMAX = 50;
const ll S = VMAX * NMAX * VMAX;
// ナップザックDPにおける価値の最大値
struct Goods {
ll v, m, w;
};
int main() {
ll N, W;
std::ci... | CPP |
p02322 Knapsack Problem with Limitations II | You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most $W$, that is capacity of the knapsack.
* You ... | 7 | 0 | #include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef unsigned long long ull;
typedef struct Item {
ull v;
ull w;
Item(ull v, ull w) : v(v), w(w) {};
} Item;
bool sort_by_cost(const Item& lhs, const Item& rhs) {
if ((__int128)lhs.v*rhs.w != (__int128)rhs.v*... | CPP |
p02322 Knapsack Problem with Limitations II | You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most $W$, that is capacity of the knapsack.
* You ... | 7 | 0 | #!/usr/bin/env python3
# DPL_1_I: Combinatorial - Knapsack Problem with Limitations II
from heapq import heappush, heappop
def max_value(t, xs):
def _cost(weight, value, i):
for j in range(i, n):
v, w = xs[j]
if weight + w > t:
return (-value, -value - (v/w)*(t-wei... | PYTHON3 |
p02322 Knapsack Problem with Limitations II | You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most $W$, that is capacity of the knapsack.
* You ... | 7 | 0 | #include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
using P = pair<ll, ll>; // (v, w)
#define fst first
#define snd second
vector<P> ps;
pair<l... | CPP |
p02322 Knapsack Problem with Limitations II | You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most $W$, that is capacity of the knapsack.
* You ... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=50001;
const ll INF=1LL<<60;
int main(){
int N;
ll W;cin>>N>>W;
ll ans=0;
vector<ll> v(N),w(N),m(N);
for(int i=0;i<N;i++){
cin>>v[i]>>w[i]>>m[i];
... | CPP |
p02322 Knapsack Problem with Limitations II | You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most $W$, that is capacity of the knapsack.
* You ... | 7 | 0 | from typing import Tuple, List
from heapq import heappush, heappop
def max_value(max_weight: int, items: List[Tuple[int, int]]) -> float:
def _cost(weight: int, value: int, i: int) -> Tuple[int, float]:
# Use value as negative cost
for j in range(i, n):
v, w = items[j]
if (... | PYTHON3 |
p02322 Knapsack Problem with Limitations II | You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most $W$, that is capacity of the knapsack.
* You ... | 7 | 0 | def main():
from collections import deque
from functools import cmp_to_key
N, W, *A = map(int, open(0).read().split())
A = [list(a) for a in zip(*[iter(A)]*3)]
Vmax = max(v for v, w, m in A)
Vsum = 0
B = []
for i, (v, w, m) in enumerate(A):
m_upper = min(m, Vmax-1)
... | PYTHON3 |
p02322 Knapsack Problem with Limitations II | You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most $W$, that is capacity of the knapsack.
* You ... | 7 | 0 | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
vector<pll> items;
ll best;
bool cmp(const pll &a,const pll &b)
{
ll x=a.first*b.second,y=a.second*b.first;
if(x!=y) return x>y;
else return a.first>b.first;
}
pair<ll,bool> estimate(int i,ll w)
{
ll r... | CPP |
p02322 Knapsack Problem with Limitations II | You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most $W$, that is capacity of the knapsack.
* You ... | 7 | 0 | #include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;
int main()
{
ll i,j;
ll n, W;
cin >> n >> W;
vector<ll> v(n);
vector<ll> w(n);
vector<ll> m(n);
f... | CPP |
p02322 Knapsack Problem with Limitations II | You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most $W$, that is capacity of the knapsack.
* You ... | 7 | 0 | #!python3
iim = lambda: map(int, input().rstrip().split())
from heapq import heappush, heappop
def resolve():
N, W = iim()
S = [list(iim()) for i in range(N)]
def f1(v, w, m):
mm = []
i = 1
while i <= m:
yield i
m -= i
i <<= 1
if m:
... | PYTHON3 |
p02322 Knapsack Problem with Limitations II | You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most $W$, that is capacity of the knapsack.
* You ... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
typedef pair< long long, long long > P;
bool sort_cost( const P &l, const P &r )
{
if( (__int128)l.second * r.first != (__int128)r.second * l.first ) {
return (__int128)l.second * r.first > (__int128)r.second * l.first;
}
else {
return l.second > r.second;
}
}
l... | CPP |
p02322 Knapsack Problem with Limitations II | You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most $W$, that is capacity of the knapsack.
* You ... | 7 | 0 | #include <bits/stdc++.h>
#include <cmath>
using namespace std;
typedef long long ll;
//typedef unsigned long long ll;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e... | CPP |
p02322 Knapsack Problem with Limitations II | You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most $W$, that is capacity of the knapsack.
* You ... | 7 | 0 | // includes
#include <bits/stdc++.h>
// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin... | CPP |
p02322 Knapsack Problem with Limitations II | You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most $W$, that is capacity of the knapsack.
* You ... | 7 | 0 | #include <bits/stdc++.h>
#define show(x) std::cerr << #x << " = " << (x) << std::endl
using ll = long long;
template <typename T>
constexpr T INF() { return std::numeric_limits<T>::max() / 16; }
template <typename T, typename A>
std::ostream& operator<<(std::ostream& os, const std::vector<T, A>& v)
{
os << "[";
... | CPP |
p02322 Knapsack Problem with Limitations II | You have $N$ items that you want to put them into a knapsack. Item $i$ has value $v_i$, weight $w_i$ and limitation $m_i$.
You want to find a subset of items to put such that:
* The total value of the items is as large as possible.
* The items have combined weight at most $W$, that is capacity of the knapsack.
* You ... | 7 | 0 | #include <iostream>
#include <vector>
#include <deque>
#include <algorithm>
using namespace std;
class Item {
public:
long long v, w, m;
explicit Item(long long v, long long w, long long m) : v(v), w(w), m(m) {}
bool operator < (const Item& it) const { return v * it.w < it.v * w; }
};
int main(){
int... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
int main()
{
long long n,m;
cin>>n;
m=sqrt(n);
cout<<n<<":";
for(int i=2;i<=n;i++)
{
while(n%i==0){
cout<<" "<<i;
n/=i;
}
if(n==1)
break;
if(i>=sqrt(n))
{
cout<<" "<<n;
brea... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
int main(){
int n;
int tmp = 2;
queue<int> que;
cin >> n;
int ans = n;
while(n > 1 && tmp*tmp <= n){
if(n % tmp == 0){
que.push(tmp);
n /= tmp;
}else{
tmp++;
}
}
if(n > 1){
que.push(n);
}
cout << ans << ":";
while... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 |
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main {
void run() {
Scanner sc = new Scanner(System.in);
long n = sc.nextLong();
Map<Long, Long> map = primeFactorization(n);
System.out.print(n + ":");
map.ent... | JAVA |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | def primefactor(x):
fac=[]
for i in xrange(2,int(x**0.5)+1):
while x%i==0:
fac+=[i]
x=x/i
if x!=1:
fac+=[x]
return fac
n=input()
ans=primefactor(n)
print(str(n)+":"+" "+" ".join(map(str,ans))) | PYTHON |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | //
#include<iostream>
using namespace std;
int main() {
int n;
cin >> n;
int x=n;
cout << n << ":";
for(int i=2; i*i<=x; i++) {
while(n%i==0) {
cout << " " << i;
n/=i;
}
}
if(n!=1)
cout << " " << n;
cout << endl;
return 0;
}
| CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <iostream>
#include <cmath>
#include <sstream>
using namespace std;
int main()
{
int n;
cin >> n;
int limit = sqrt(n);
stringstream ss;
ss << n << ":" ;
for (int i = 2; i <= sqrt(n); i++) {
//int count;
while (n % i == 0) {
n /= i;
ss << " " << i;
//count ++;
}
}
... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | import math
n=int(input())
factors=[]
n1=n
p=2
while p<=math.sqrt(n):
if n%p==0:
n//=p
factors.append(str(p))
else:
p+=1
if n!=1:
factors.append(str(n))
print(str(n1)+": "+" ".join(factors))
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | import java.util.Scanner;
//?´??????°????§£?????????????????°??????
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
long n = Long.parseLong(sc.nextLine());
System.out.print(n + ":");
for (int i = 2; n >= i * i;) {
if (n % i == 0) {
n = n / i;
Syste... | JAVA |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ll n;
cin >> n;
vector<ll> ans;
cout << n << ":";
for(ll i = 2; i*i <= n; i++){
while(n % i == 0){
ans.emplace_back(i);
n /= i;
}
}
if(n != 1) ans.emplace_back(n);
... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | m=input();n=int(m);s=n**.5;a=[];i=6
while n%2==0:a+=[2];n//=2
while n%3==0:a+=[3];n//=3
while i<s:
if n%(i-1)==0:a+=[i-1];n//=i-1
elif n%(i+1)==0:a+=[i+1];n//=i+1
else:i+=6
if n>1:a+=[n]
elif n==int(m):a+=[m]
print(m+':',*a)
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include<iostream>
#include<stdio.h>
#include<vector>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
int n;
cin >> n;
cout << n << ":";
int ren = n;
for (int i = 1; i <= sqrt(n); i++)
{
while (ren != 1)
{
if (ren % (i + 1) == 0)
{
cout << " " <<i + 1;
ren = ren / (i +... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
signed main(void)
{
long long num; cin >> num;
cout << num << ":";
for (int i = 2; i*i <= num; ++i)
while (num % i == 0)cout << " " << i, num /= i;
if (num != 1)cout << " " << num; cout << endl;
} | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | n=int(input())
s=str(n)+":"
b=True
d=n
i=2
while b:
if d%i==0:
d/=i
s+=' '+str(i)
i-=1
b=i<d**0.5
i+=1
if d!=1:s+=' '+str(int(d))
print(s) | PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | import java.util.ArrayList;
import java.util.Scanner;
public class Main {
private static int nowSosuu = 1;
private static ArrayList<Integer> array = new ArrayList<Integer>();
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
System.out.printf(n + ":");
... | JAVA |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include<iostream>
#include<cmath>
using namespace std;
int main(){
int n;
cin>>n;
cout<<n<<":";
for(int i=2;i<=sqrt((double)n);){
if(n%i==0){
cout<<" "<<i;
n/=i;
}
else i++;
}
if(n!=0) cout<<" "<<n;
cout<<endl;
} | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
long long n,i;
cin>>n;
cout<<n<<":";
i=2;
while(n>1 && i*i<=n){
if(n%i==0){
cout<<" "<<i;
n/=i;
}
else i+=1;
}
if(n!=1)cout<<" "<<n;
cout<<endl;
return 0;
} | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | import java.util.Scanner;
import java.util.*;
public class Main{
public static void main(String[] args){
ArrayList<Integer> list =new ArrayList<Integer>();
Scanner sc = new Scanner(System.in);
int a= sc.nextInt();
int b=a;
for(int i=2;i<b/2;i++){
while(a%i==0){
... | JAVA |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60; // INFの値は1152921504606846976
int main()
{
int n;
cin >> n;
cout << n << ':';
for(int i = 2; i * i <= n; i++){
while(... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include <iostream>
#include <stdio.h>
using namespace std;
bool IsPrime(int n){
for(int i=2;i*i<=n;i++){
if(n%i==0) return false;
}
return true;
}
int main() {
int n;
cin >> n;
cout << n <<":";
if(IsPrime(n)) cout << " " << n;
else{
while(IsPrime(n)!=true){
for(int i=2;i<=n&&n!=1;i++){
whil... | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | p=lambda x:print(x,end=' ')
n=input();p(n+':')
n=int(n);s=n**.5
while n%2==0 and n>3:p(2);n//=2
d=3
while s>d and n>d:
if n%d>0:d+=2
else:p(d);n//=d
print(n)
| PYTHON3 |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | #include<iostream>
using namespace std;
int main()
{
int n;
cin>>n;
int save=n;
cout<<n<<":";
for(int i=2;i*i<=save;i++)
if(n%i==0)
{
while(n%i==0){
n/=i;
cout<<" "<<i;
}
}
if(n>1)
cout<<" "<<n;
cout<<endl;
return 0;
} | CPP |
p02467 Prime Factorize | Factorize a given integer n.
Constraints
* 2 ≤ n ≤ 109
Input
n
An integer n is given in a line.
Output
Print the given integer n and :. Then, print prime factors in ascending order. If n is divisible by a prime factor several times, the prime factor should be printed according to the number of times. Print a s... | 7 | 0 | def prime_factorize(n):
a=[]
while n%2==0:
a.append(2)
n //=2
f=3
while f**2<=n:
if n%f==0:
a.append(f)
n //=f
else:f +=2
if n!=1:a.append(n)
return a
n=int(input())
A=prime_factorize(n)
print("{}:".format(n),*A)
| PYTHON3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.