Source
stringclasses
1 value
Date
int64
2.01k
2.02k
Text
stringlengths
22
783k
Token_count
int64
20
394k
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; #define int long long #define endl '\n' #define maxn 2010 const int MOD = 1000000007; int dp[maxn][maxn]; pair<int, int> v[maxn]; int n; int solve(int id, int l, int r) { if (id > n)return 0; int &ans = dp[l][r]; if (ans != -1) return ans; ans = ...
313
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; #define name "" #define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout) #define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++) #define long long long #define db double #define pii pair <int, int> #define pll pair <long, long> #d...
447
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; const int MAX_N = 2005; long long dp[MAX_N][MAX_N]; int n; int a[MAX_N]; pair <int, int> save[MAX_N]; bool comp(pair <int, int> a, pair <int, int> b) { return (a.first > b.first || (a.first == b.first && a.second < b.second)); } int main () { //freopen("input.t...
432
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; using Int = long long; int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0); //int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0); template <class T> void chmax(T& x, T y) { if (x < y) ...
414
Project_CodeNet
2,020
// includes #include <bits/stdc++.h> using namespace std; // macros #define pb emplace_back #define mk make_pair #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(); itr != (st).end(); ++itr) ...
1,184
Project_CodeNet
2,020
#include<iostream> #include<fstream> #include<cstdio> #include<algorithm> #include<cmath> #include<vector> #include<deque> #include<set> #include<map> #include<bitset> #include<ctime> #include<queue> using namespace std; #define int long long #define pii pair <int, int> #define XX first #define YY second // constants:...
794
Project_CodeNet
2,020
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define int long long #define ull unsigned long long #define ld long double #define rep(a) rep1(i,a) #define rep1(i,a) rep2(i,0,a) #define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++) #define rep3(i,b,a) for(int i=...
707
Project_CodeNet
2,020
#include<iostream> #include<iomanip> #include<cmath> #include<string> #include<vector> #include<algorithm> #include<map> #include<set> #include<queue> #include<stack> using namespace std; typedef long long ll; #define fi first #define se second #define mp make_pair const int inf=1e9+7; const ll mod=1e9+7; long DP[2005...
395
Project_CodeNet
2,020
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (n); ++i) using namespace std; #define INF ((1<<30)-1) #define LINF (1LL<<60) 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; } type...
335
Project_CodeNet
2,020
#include <bits/stdc++.h> #define long long long int using namespace std; // @author: pashka int main() { ios::sync_with_stdio(false); int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } vector<pair<int, int>> q(n); for (int i = 0; i < n; i++) { ...
379
Project_CodeNet
2,020
//17571@nith.ac.in @Ankit Verma #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; #pragma GCC optimize("O3") #define ll long long #define ld long double //--------------------------------------------------------------------------------------------------...
1,980
Project_CodeNet
2,020
#include<bits/stdc++.h> const int mod=1e9+7; typedef long long ll; const int N=2e3+5; int n; std::vector<std::pair<ll,int> > v; ll dp[N][N]; ll solve(int l,int r) { if(dp[l][r]>=0) return dp[l][r]; if(r<l) return dp[l][r]=0; int i=n-r+l;//当前正在放第i个 return dp[l][r]=std::max( v[i].first*std::abs(v[i].second-l)+solv...
258
Project_CodeNet
2,020
#include <stdio.h> #include <algorithm> using namespace std; int N; pair<int, int> P[2020]; long long D[2020][2020]; int main() { scanf ("%d", &N); for (int i = 0; i < N; i++) scanf ("%d", &P[i].first), P[i].second = i; sort(P, P + N); reverse(P, P + N); for (int i = 0; i < N; i++) for (int j = 0; i + j < N; j+...
271
Project_CodeNet
2,020
#include <iostream> #include <fstream> #include <cstdio> #include <cmath> #include <vector> #include <string> #include <set> #include <map> #include <stack> #include <queue> #include <deque> #include <bitset> #include <algorithm> #include <complex> #include <array> #include <functional> using namespace std; #define R...
506
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<LL, LL> PII; // chmax, chmin 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; } r...
795
Project_CodeNet
2,020
#include <iostream> #include <fstream> #include <cstdio> #include <cmath> #include <vector> #include <string> #include <set> #include <map> #include <stack> #include <queue> #include <deque> #include <bitset> #include <algorithm> #include <complex> #include <array> #include <functional> using namespace std; #define R...
506
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define rep(i, n) for (ll i = 0; i < (ll)(n); i++) ll ans = 0; int main() { ll n ; cin >> n ; vector<pair<ll,ll>> a(n); rep(i, n){ cin >> a[i].first; a[i].second=i+1; } sort(a.begin(),a.end()); reverse(a.begin(),a.end()); vector<vector<ll>> v(n+1...
238
Project_CodeNet
2,020
#include<bits/stdc++.h> #define INF 1e9 #define llINF 1e18 #define MOD 1000000007 #define pb push_back #define mp make_pair #define F first #define S second #define ll long long #define vi vector<ll> #define vvi vector<vi> #define BITLE(n) (1LL<<((ll)n)) #define SHIFT_LEFT(n) (1LL<<((ll)n)) #define SUBS(s,f,t) ((s).su...
443
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MAXN = 2005; pair<ll, int> a[MAXN]; int n; ll memo[MAXN][MAXN]; ll dp(int L, int R) { if(L > R) return 0; if(memo[L][R] != -1) return memo[L][R]; int i = L + (n-1-R); ll& ans = memo[L][R]; ll on_left = a[i].first * abs(...
265
Project_CodeNet
2,020
#pragma GCC optimize("Ofast",3,"inline") #include<bits/stdc++.h> #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 MOD=1000000007; const int INF=0x3f3f3f3f; const ll INFL=0x3f3f3f3f3f3f3f3f; int a[3000]; ll dp[3000][3000]; int main(){ int n;cin>>n; ve...
294
Project_CodeNet
2,020
#include<bits/stdc++.h> using namespace std; #define int long long #define x first #define y second #define pb push_back #define mp make_pair #define all(a) (a).begin(), (a).end() const int N = 2005; int dp[N][N]; inline void upd(int &x, int y) { x = max(x, y); } int32_t main() { ios::sync_with_stdio(fal...
317
Project_CodeNet
2,020
#include<bits/stdc++.h> #define ll long long #define xx first #define yy second using namespace std; ll mem[2003][2003], n; typedef pair<ll, int>pi; pi p[2003]; ll dp(int l, int r) { if(l>r)return 0; if(mem[l][r]!=-1)return mem[l][r]; int pos= l+n-r-1; return mem[l][r]= max(p[pos].xx*abs(p[pos].yy-l)+dp...
220
Project_CodeNet
2,020
#include<bits/stdc++.h> //#include<iostream> //#include<cstdio> //#include<stdlib.h> //#include<string.h> //#include<algorithm> using namespace std; #define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0) #define READ freopen("in.txt","r",stdin) #define WRITE freopen("out.txt","w",stdout); #define pb push_ba...
775
Project_CodeNet
2,020
// IOI 2021 #include <bits/stdc++.h> using namespace std; #define endl '\n' #define ends ' ' #define die(x) return cout << x << endl, 0 #define all(v) v.begin(), v.end() #define sz(x) (int)(x.size()) void debug_out() { cerr << endl; } template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr ...
464
Project_CodeNet
2,020
#include <bits/stdc++.h> #define rep(i,n) for (int i = 0; i < (n); ++i) #define ok() puts(ok?"Yes":"No"); using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int, int> ii; typedef vector<vi> vvi; typedef vector<ii> vii; typedef vector<bool> vb; typedef vector<vb> vvb; typedef set<int> si; ty...
432
Project_CodeNet
2,020
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define int long long #define endl '\n' #define pb push_back #define fi first #define se second #define all(c) (c).begin(),(c).end() typedef long long ll; typedef long ...
618
Project_CodeNet
2,020
#include<bits/stdc++.h> using namespace std; typedef long long ll; ll dp[2005][2005]; // dp[i][j] 前 i 个人放了 j 个左边的 ll n,ma; struct stu { ll pos,w; }a[2004]; bool cmp(stu u,stu v) { return u.w<v.w; } int main() { cin>>n; for(int i=1;i<=n;i++) { scanf("%lld",&a[i].w); a[i].pos=i; ...
334
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define ar array #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_u...
1,547
Project_CodeNet
2,020
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using namespace std; typedef long long int lli; #define int lli typedef pair<int, int> pii; typedef pair<lli, lli> pll; typedef vector<int> vi; typedef vector<lli> vli; typedef vector<pii> vii; typedef tree<int, null_type, l...
1,020
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; // 両端から活発な子を詰めていくのが最適 // {Ai | 1<= i <= N, Aiは降順} Ai := 活発さ // {Pi | 1<= i <= N} Pi := Aiの子供の位置 // dp[x][y] := 活発度の高い方から(x+y)人選び、x人左、y人右に詰めていったときの最大値 // dp[x][y] <- dp[x-1][y] + A[x+y]*abs(P[i] - x) // dp[x][y] <- dp[x][y-1] + A[x+y]*abs(P[i] - (N - y + 1)) int main() { ...
483
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; #define SZ(v) ((int)(v).size()) using ll = long long; int main(void) { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int nb_enfants; cin >> nb_enfants; vector<pair<ll, int> > val(nb_enfants); for (int i = 0; i < nb_enfants; ++i) { cin >> val[i].first...
342
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; vector<int> A(N, 0); vector<int> index(N, 0); for (int i = 0; i < N; i++) { cin >> A[i]; index[i] = i; } // 降順ソート vector<int> B(N, 0); B = A; for (int i = 0; i < N; i++) { for (int j = i; j > 0; j--) { i...
417
Project_CodeNet
2,020
// https://twitter.com/armeria_betrue/status/1251868789773238273 // を見て実装 #include <algorithm> #include <array> #include <cassert> #include <climits> #include <cmath> #include <cstdio> #include <cstring> #include <deque> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #in...
1,220
Project_CodeNet
2,020
#include <bits/stdc++.h> #define ll long long #define intm INT_MAX #define llm LLONG_MAX #include <iomanip> using namespace std; int MOD = 998244353; const int mxN = 2e3 + 9; ll dp[mxN][mxN]; pair<ll,ll> ar[mxN]; int main(){ ios_base::sync_with_stdio(false); cin.tie(0); ll N; ll ai; cin >> N; priority_queue<pair...
374
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; #define int long long // #define double long double #define FOR(i, a, b) for(int i = (a); i < (b); ++i) #define FORR(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)...
1,879
Project_CodeNet
2,020
#include <bits/stdc++.h> #define FAST ios_base::sync_with_stdio(false); #define FO cout.tie(NULL); #define FI cin.tie(NULL); #define IN cin>> #define OUT cout<< #define loop(i,a,n) for(int i=a; i<n; i++) #define rloop(i,a,n) for(int i=a; i>=n; i--) #define endl "\n"; #define pb push_back #define mp make_pair #define se...
732
Project_CodeNet
2,020
#pragma GCC optimize("Ofast") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx") #pragma GCC optimize("unroll-loops") //#pragma warning(disable : 4996) #ifdef _MSC_VER #include <intrin.h> #define __builtin_popcount __popcnt #endif #include<iostream> #include<string> #include<algorithm> #include<vector>...
880
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; #define ll long long #define mod 1000000007 #define pb push_back #define pi pair<int,int> #define vi vector<int> #define vpi vector< pi > #define IOS ios_base::sync_with_stdio(false),cin.tie(NULL) const int N=2003; int a[N],n; vpi v; ll dp[N][N]; ll solv(int i,int l) { ...
301
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; using int32 = int_fast32_t; using int64 = int_fast64_t; const int32 INF = 1e9; const int32 MOD = 1e9+7; const int64 LLINF = 1e18; #define YES(n) cout << ((n) ? "YES\n" : "NO\n" ) #define Yes(n) cout << ((n) ? "Yes\n" : "No\n" ) #define POSSIBLE cout << ((n) ? "POSSIBLE...
538
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; int main(){ long long N; cin >> N; vector<pair<long long,long long>> A(N); for(int i=0;i<N;i++){ long long a; cin >> a; A[i] = make_pair(a,i); } sort(A.rbegin(),A.rend()); vector<vector<long long>> dp(N+1,vector<long long>(N+1,0)); for(int i=...
244
Project_CodeNet
2,020
#include<bits/stdc++.h> using namespace std; typedef long long int ll; #define mod 1000000007 #include<string.h> #define inf 9000000000000000000 #define maxn 200006 typedef pair<ll,ll> pll; typedef pair<int,int> pint; #define endl '\n' #define mapint_iterator map<int,int> :: iterator #define mapll_iterator map<ll,ll> :...
1,098
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; using Graph = vector<vector<ll>>; #define rep(i, n) for(ll i=0;i<(ll)(n);i++) #define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++) #define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--) const int dx[4] = {1, 0, -1, 0}; const int dy[4] = ...
539
Project_CodeNet
2,020
#include<iostream> #include<cstdio> #include<queue> #include<vector> #include<string.h> #include<algorithm> #include <cmath> using namespace std; long long N,K,i,j,k,MOD,ans,n1,n2,t,memo[2001][2001]; vector<pair<long long,long long>> A; long long dp(long long n,long long m) { if(memo[n][m]!=-1) return memo[n][m]...
341
Project_CodeNet
2,020
#pragma GCC optimize ("O3") #pragma GCC target ("sse4") #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; typedef complex<ld> cd; typedef pair<int, int> pi; typedef pair<ll,ll> pl; typedef pair<ld,ld> pd; typedef vector<int> vi; typedef vector<ld> vd; typedef vector<l...
632
Project_CodeNet
2,020
#include <bits/stdc++.h> #define ll long long #define ld long double #define pii pair<int, int> #define pll pair<ll, ll> #define str string #define fi first #define se second #define pb push_back #define SET(a, b) memset(a, b, sizeof(a)) #define eps 1e-6 #define pi atan(1) * 4 #define mod 1000000007 #define inf 1000000...
477
Project_CodeNet
2,020
#define _STRESS #ifdef STRESS #include "Base.h" #else #pragma comment(linker, "/STACK:66777216") #define _USE_MATH_DEFINES #include <iostream> #include <vector> #include <math.h> #include <algorithm> #include <unordered_set> #include <unordered_map> #include <map> #include <set> #include <bitset> #include <ctime> #in...
1,347
Project_CodeNet
2,020
#include<algorithm> #include<bitset> #include<cassert> #include<cfloat> #include<climits> #include<cmath> #include<deque> #include<functional> #include<iomanip> #include<iostream> #include<map> #include<queue> #include<array> #include<set> #include<stack> #include<string> #include<unordered_map> #include<unordered_set>...
2,101
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<int, int>; ll dp[2005][2005]; int main() { ll n; cin >> n; pair<ll, ll> a[n]; for (ll i = 0; i < n; i++) { cin >> a[i].first; a[i].second = i; } sort(a, a + n, greater<pair<ll, ll>>()); ll an...
272
Project_CodeNet
2,020
#include "bits/stdc++.h" using namespace std; #define sim template < class c #define ris return * this #define dor > debug & operator << #define eni(x) sim > typename \ enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) { sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; } s...
1,018
Project_CodeNet
2,020
#include <bits/stdc++.h> #define ll long long using namespace std; const int N = 2e3 + 5; ll f[N][N]; pair<int, int> p[N]; ll cal(int cnt, int l, int r) { if(l > r) return 0; if(~f[l][r]) return f[l][r]; ll ans = 1LL * p[cnt].first * abs(p[cnt].second - l) + cal(cnt + 1, l + 1, r); ans = max(ans, 1LL * ...
285
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; #define modulo 1000000007 #define mod(mod_x) ((((long long)mod_x+modulo))%modulo) #define Inf 10000000000000000 int main(){ int N; cin>>N; vector<pair<long long,long long>> A(N); for(int i=0;i<N;i++){ cin>>A[i].first; A[i].second = i; } sort(A.rbegin(),A.re...
309
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define INF 1e18 int main() { int N; cin >> N; vector<pair<ll, int>> A(N); for (int i = 0; i < N; i++) cin >> A[i].first, A[i].second = i; sort(A.begin(), A.end(), greater<pair<ll, ll>>()); vector<vector<ll>> dp(N + 1, vector<...
337
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; using i64 = long long; #define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++) #define all(x) x.begin(),x.end() template<class T> static inline std::vector<T> ndvec(size_t&& n, T val) noexcept { return std::vector<T>(n, std::forward<T>(val)); } template<class... Tail> sta...
982
Project_CodeNet
2,020
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update> using namespace std; using namespace __gnu_pbds; #define int long long int #define pb push_back #de...
650
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; using ld = long double; using ll = long long; ll dp[2100][2100]; int main() { cout.precision(20); ios_base::sync_with_stdio(false); int n; cin >> n; vector<pair<int, int>> v(n); for (int i = 0; i < n; i++) { cin >> v[i].first; v[i]...
338
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;} template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();} typedef long long ll; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<long long> VL; type...
693
Project_CodeNet
2,020
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; // #define int long long // #define double long double #define rep(i,n) for (int i=0; i<(int)(n); ++i) #define rep1(i,n) for (int i=1; i<(int)(n); ++i) #define repeq(i,n) for (int i=0; i<=(int)(n); ++i) #define rep1eq(i,n) for (int i=1; i<=(int)(n)...
1,358
Project_CodeNet
2,020
#include <iostream> #include <vector> #include <algorithm> #include <numeric> // #include <queue> // #include <cmath> // #include <string> // #include <set> // #include <map> // #include <iomanip> // #define MOD 1000000007 // #define INF 1000000001 using namespace std; // typedef unsigned long long ull; typedef long ...
497
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std::literals::string_literals; using i64 = std::int_fast64_t; using std::cout; using std::cerr; using std::endl; using std::cin; template<typename T> std::vector<T> make_v(size_t a){return std::vector<T>(a);} template<typename T,typename... Ts> auto make_v(size_t a,Ts... ts){...
407
Project_CodeNet
2,020
#include<bits/stdc++.h> using namespace std; typedef long long int ll; const int N = 2e3 + 5; ll dp[N][N]; int main () { ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0); int n; cin >> n; vector < pair < int, int > > a (n + 1); for (int i = 1; i <= n; i++) cin >> a[i].first, a[i].second = i; ...
302
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 2e3 + 5; struct Node { int val, pos; bool operator < (const Node &rhs) const { return val > rhs.val; } } a[maxn]; ll dp[maxn][maxn], res; // dp[i][j] 表示左边放i个右边放j个的最大值 int main() { int n; scanf("%d", &...
352
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; using ll = long long; constexpr int inf = 0x3f3f3f3f; constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL; int n; ll a[2000]; int id[2000]; ll dp[2001][2001]; ll rec(int i, int j) { if (dp[i][j] != -1) return dp[i][j]; ll res = 0; if (i - 1 >= 0) res = max(res, rec(i -...
380
Project_CodeNet
2,020
#include <stdio.h> #include <stdlib.h> #include <iostream> #include <math.h> #include <algorithm> #include <string> #include <string.h> #include <vector> #include <functional> #include <queue> using namespace std; typedef long long ll; struct Infant { ll x; ll A; bool operator<( const Infant& right ) const { ret...
419
Project_CodeNet
2,020
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<bitset> #include<cassert> #include<cctype> #include<cmath> #include<cstdlib> #include<ctime> #include<deque> #include<iomanip> #include<list> #include<map> #include<queue> #include<set> #include<stack> #include<vector> using namespace st...
490
Project_CodeNet
2,020
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~= WRITER:kakitamasziru/OxOmisosiru ~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/ #define _GLIBCXX_DEBUG #include <iostream> // cout, endl, cin #include <string> // string, to_string, stoi #include <vector> // vector #include <algorithm> // min, max, swap, sort, reverse, lower_bound...
957
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; int n; long long dp[2001][2001], ans = 0; vector<pair<int, int>> a; int main() { cin >> n; for (int i = 0, m; i < n; i++) { cin >> m; a.emplace_back(m, i); } sort(a.begin(), a.end(), greater<pair<int, int>>()); for (int i = 0; i < n; i++) { //既にi人並んでいる for (in...
317
Project_CodeNet
2,020
/************************************************************************* > File Name: B.cpp > Author: Knowledge_llz > Mail: 925538513@qq.com > Created Time: 2020/4/19 20:41:09 ************************************************************************/ #include<iostream> #include<cstdio> #include<cstdlib> #includ...
421
Project_CodeNet
2,020
#include <iostream> #include <vector> #include <algorithm> #include <utility> #include <string> #include <queue> #include <stack> using namespace std; typedef long long int ll; typedef pair<int, int> Pii; const ll mod = 1000000007; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; ve...
365
Project_CodeNet
2,020
#include <bits/stdc++.h> #define ll long long int using namespace std; template <class T1, class T2>void print(T1 a[], T2 n) { for (T2 i = 0; i < n; i++) { cout << a[i] << " ";} cout << endl;} template <class T1, class T2>void print(vector<T1> a, T2 n) { for (T2 i = 0; i < n; i++) { cout << a[i] << " "; } cout << endl;...
441
Project_CodeNet
2,020
///Bismillahir Rahmanir Rahim #include<bits/stdc++.h> #define int long long #define fi first #define si second #define mp ...
471
Project_CodeNet
2,020
#include<bits/stdc++.h> using namespace std; int main(){ long long i,j,N,M; cin>>N; vector<pair<long long,long long>> v(N); vector<vector<long long>> dp(N+1,vector<long long>(N+1,0)); for(i=0;i<N;++i){ cin>>v[i].first; v[i].second=i; } //降順ソート sort(v.rbegin(),v.rend()); //(配る)dp for(i=0;i<N;...
251
Project_CodeNet
2,020
#include <cstdio> #include <cstdint> #include <cinttypes> #include <iostream> #include <vector> #include <utility> #include <cmath> #include <algorithm> #include <numeric> #include <string> using namespace std; using u8t = std::uint64_t; using i8t = std::int64_t; #define F(I,N) for(i8t I=0,I##_N=N;I<I##_N;I++) #define ...
564
Project_CodeNet
2,020
#include <bits/stdc++.h> #define ll long long int #define uu first #define vv second #define pii pair<int,int> #define pll pair<ll,ll> #define INF 1e9 #define fastRead ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0) using namespace std; const int MAX = 2000 + ...
317
Project_CodeNet
2,020
#include<bits/stdc++.h> using namespace std; using ll = long long; #define debug(x) cout << #x << " = " << x << endl; #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it) #define MSET(c, v) memset(c, v, sizeof(c)) const int IN...
604
Project_CodeNet
2,020
#include<bits/stdc++.h> using namespace std; // #include <ext/pb_ds/assoc_container.hpp> // Policy_based_Data_Structure // #include <ext/pb_ds/tree_policy.hpp> // using namespace __gnu_pbds; /*#include <boost/multiprecision/cpp_int.hpp> using namespace boost::multiprecision;*/ #pragma GCC target ("avx2") #pragma GCC...
2,396
Project_CodeNet
2,020
#include<bits/stdc++.h> using namespace std; #define ll long long const int maxn=2e3+5; const int mod=1e9+7; ll dp[maxn][maxn]; struct ac { ll p,v; }; ac a[maxn]; bool cmp(ac a,ac b) { return a.v>b.v; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin>>n; for(int i=1;i<=n;i++...
338
Project_CodeNet
2,020
#define _USE_MATH_DEFINES #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <cctype> #include <climits> #include <clocale> #include <cmath> #include <cstdio> #include <cstdlib> #include <ctime> #include <deque> #include <fstream> #include <functional> #include <iomanip> #include <iostr...
573
Project_CodeNet
2,020
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define For(i,n,k) for(int i=(n);i<(k);i++) #define ALL(a) (a).begin(),(a).end() ll ans=0; void Main(){ ll n;cin>>n; vector<pair<ll,ll>> a(n+1); a[0]=make_pair(1e9+7,1e9+7); For(i,1,n+1) { cin>>a[i].first; a[i].second=i;...
404
Project_CodeNet
2,020
#include <algorithm> #include <functional> #include <iostream> #include <iomanip> #include <vector> #include <map> #include <set> #include <unordered_set> #include <queue> #include <numeric> #include <bitset> #include <cmath> #include <random> using namespace std; using ll = long long; using ull = unsigned long long; ...
1,494
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<string> vs; typedef pair<int, int> pii; #define sz(a) int((a).size()) #define pb push_back #define mp make_pair #define fi first #define se second #define all(c) (c).begin(),(c).end() #...
933
Project_CodeNet
2,020
#include <iostream> #include <string> #include <vector> #include <list> #include <map> #include <queue> #include <stack> #include <algorithm> #include <fstream> #include <sstream> #include <iomanip> #define ll long long using namespace std; long long MOD = 1000000007; int main(){ int N; cin >> N; vector<...
293
Project_CodeNet
2,020
/* Akshat Sharma @akshat98 */ #include <iostream> #include <bits/stdc++.h> #define IOS ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0) #define mp make_pair #define pb push_back #define F first #define S second #define ll long long #define MOD 1000000007 #define MAX 1000000001 #define vi vecto...
513
Project_CodeNet
2,020
#include <iostream> #include <vector> #include <array> #include <set> #include <cmath> #include <string> #include <sstream> #include <queue> #include <list> #include <stack> #include <unordered_map> #include <algorithm> #include <numeric> #include <functional> #include <cassert> #include <bitset> #include <cctype>...
621
Project_CodeNet
2,020
/* auth - @sportykush */ #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; typedef long long int ll; typedef long double ld; typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> orde...
864
Project_CodeNet
2,020
#include<iostream> #include<algorithm> #define ll long long using namespace std; const int N=2e3+5; ll dp[N][N]; struct node { int x,id; }; node a[N]; int cmp(node a,node b) { return a.x>b.x; } int main() { int n; cin>>n; for(int i=1;i<=n;i++) { cin>>a[i].x; a[i].id=i; } sort(a+1,a+n+1,cmp); for(int k=1;k<...
257
Project_CodeNet
2,020
#include <iostream> #include <vector> #include <algorithm> #include <utility> using namespace std; int main() { int N; cin>>N; vector<long long> A(N); for (long long &a: A) cin>>a; vector<pair<long long, int>> V(N); for (int i=0; i<N; i++) V[i] = make_pair(A[i], i); sort(V....
255
Project_CodeNet
2,020
#include <bits/stdc++.h> #define ll long long int #define MOD 1000000007 using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ll n; cin>>n; vector<pair<ll,ll>> v(n+1); for(int i=1;i<=n;i++){ cin>>v[i].first; v[i].second = i; } sort(v.begin(),v.end()); ll...
236
Project_CodeNet
2,020
#include <iostream> #include <vector> #include <set> #include <unordered_set> #include <map> #include <unordered_map> #include <cstdio> #include <bitset> #include <queue> #include <deque> #include <algorithm> #include <numeric> #include <cassert> #include <functional> #include <stack> #include <cmath> #include <string>...
1,316
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; int n; long long dp[2005][2005]; vector<pair<long long, int> > v; long long solve(int l, int r) { if (r < l) return 0; if (dp[l][r] != -1) return dp[l][r]; int i = l + n - r - 1; return dp[l][r] = max(v[i].first * abs(v[i].second - l) + solve(l + 1, r), v[i].first *...
230
Project_CodeNet
2,020
//Author : Sidiq Tri Pratikto #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define pb push_back #define fi first #define se second #define mp make_pair #define all(v) v.begin(), v.end() using namespace std; using namespace __gnu_pbds; typedef tree<int, null_type...
413
Project_CodeNet
2,020
// clang-format off #include <bits/stdc++.h> #define mp make_pair #define fst first #define snd second #define forn(i,n) for (int i = 0; i < int(n); i++) #define forn1(i,n) for (int i = 1; i <= int(n); i++) #define popcnt __builtin_popcount #define ffs __builtin_ffs #define ctz __builtin_ctz #define clz __builtin_clz ...
653
Project_CodeNet
2,020
#include <bits/stdc++.h> // #undef DEBUG // Uncomment this line to forcefully disable debug print. #if DEBUG template <typename T> void debug(T value) { std::cerr << value; } template <typename T, typename... Ts> void debug(T value, Ts... args) { std::cerr << value << ", "; debug(args...); } #define dbg(...) ...
586
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); ll N; cin >> N; vector<pair<ll, ll>> P(N); for (ll i = 0; i < N; i++) { ll a; cin >> a; P[i] = make_pair(a, i); } sort(P.rbegin(), P.rend()); ll INF = 1e18; vector<ll> d...
292
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define ALL(x) (x).begin(), (x).end() const ll INF = 1001001001; const int MOD = 1000000007; const int MAX_N = 101010; // A:array of pair, N:size of array void sort_second(vector<pair<ll, ll>> &A, int N); // a^n ll a_n(ll a, ll n); // make vector of...
713
Project_CodeNet
2,020
// #pragma GCC optimize("Ofast") // #pragma GCC target("avx,avx2,fma") // #pragma GCC optimization ("unroll-loops") #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define fo(i,n) for(int i=0;i<n;i++) #d...
1,199
Project_CodeNet
2,020
#include <algorithm> #include <functional> #include <iostream> #include <utility> #include <vector> using namespace std; int main() { int n; cin >> n; vector<pair<long long, int>> a(n, make_pair(0, 0)); for (int i = 0; i < n; i++) { cin >> a[i].first; a[i].second = i; } sort(...
304
Project_CodeNet
2,020
#include<iostream> #include<cstdio> #include<cmath> #include<algorithm> using namespace std; #define ll long long #define read(x) scanf("%d",&x) struct node { int id,val; }a[2005]; ll dp[2005][2005]; int n; bool cmp(node n,node m){return n.val<m.val;} int main() { read(n); for(int i=1;i<=n;i++) read(a[i].val),a...
260
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL_DEBUG #include "LOCAL_DEBUG.hpp" #endif #define int long long template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); } template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec...
472
Project_CodeNet
2,020
// ____ ____ _ // | _ \ _ __| _ \ ___ _ __ __| |_ __ ___ // | | | | '__| | | |/ _ \ '_ \ / _` | '__/ _ \ // | |_| | |_ | |_| | __/ | | | (_| | | | (_) | // |____/|_(_)|____/ \___|_| |_|\__,_|_| \___/ // #include <...
568
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector <pair<long int,int>> a(n+1); for (int i=1; i<=n; i++) cin >> a[i].first, a[i].second = i; sort(a.rbegin(),a.rend()); vector <vector <long long int>> dp(n+1,vector <long long int>(n+1)); dp[0][0] = 0; /...
312