Source
stringclasses
1 value
Date
int64
2.01k
2.02k
Text
stringlengths
22
783k
Token_count
int64
20
394k
Project_CodeNet
2,020
#include <iostream> #include <iomanip> #include <vector> #include <set> #include <string> #include <queue> #include <algorithm> #include <map> #include <cmath> #include <numeric> #include <list> #include <stack> #include <cstdio> #include <cstdlib> #include <cstring> #include <tuple> #define rep(i, n) for (int i = 0; ...
517
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; long long dp[2020][2020]; int main() { int n; cin >> n; int a[n]; int p[n]; for (int i=0;i<n;i++) { cin >> a[i]; p[i]=i; } sort(p, p + n, [&] (int x, int y) { return a[x] > a[y]; }); for (int i = 0; i < n; i++) { for (int ...
279
Project_CodeNet
2,020
#include<bits/stdc++.h> using namespace std; //Optimisations #pragma GCC target ("avx2") #pragma GCC optimization ("unroll-loops") #pragma GCC optimize("O2") //shortcuts for functions #define pb push_back #define mp make_pair #define ff first #define ss second #define all(v) v.begin(),v.end() #define prec(n) fixed<<se...
796
Project_CodeNet
2,020
//agrawal117 //chahatagrawal117 #include<bits/stdc++.h> #define endl '\n' #define mod 1000000007 typedef long long int ll; using namespace std; #define MAX 2005 const ll oo=1000000007; vector<pair<ll,ll>> v; ll dp[MAX][MAX]; ll n; ll solve(int l, int r) { if(r<l) return 0; if(dp[l][r]!=-1) return dp[l][r]; ...
281
Project_CodeNet
2,020
#include <bits/stdc++.h> int ri() { int n; scanf("%d", &n); return n; } int main() { int n = ri(); std::pair<int, int> a[n]; for (int i = 0; i < n; i++) a[i] = {ri(), i}; std::sort(a, a + n, std::greater<>()); int64_t dp[n + 1][n + 1]; for (auto &i : dp) for (auto &j : i) j = -1000000000000000000; dp[0][0] ...
352
Project_CodeNet
2,020
#include <bits/stdc++.h> #define deb(x) cerr << (#x) << " : " << (x) << "\n" #define ll long long int #define ld long double const ll MOD = 1e9 + 7; const ll INF = 1e18; using namespace std; ll powmod(ll a, ll b, ll MOD = MOD){ if(!a and !b) return 1ll; if(!a) return a; ll res = 1ll; b %= (MOD - 1ll), a %= MOD...
483
Project_CodeNet
2,020
#pragma GCC optimize("Ofast", "unroll-loops") // #define TEST #include <bits/stdc++.h> using namespace std; #define ll long long int main() { int N; cin >> N; vector<pair<int, int>> A_idx(N); for (int i = 0; i < N; ++i) { int ai; cin >> ai; A_idx[i] = pair<int, int>(ai, i); } // (Ai,i)を降順ソート sort( A_id...
590
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; ll dp[2001][2001]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<pii> a(n); for (int i = 0; i < n; i++) { cin >> a[i].first; a[i].second = i; } sort(a.begin(), a.end(), [](...
312
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 ld long double #define endl '\n' #define vi vector<int> #define vvi vector<vi> #define pii pair<int, int> #define vpii vector<pii> #define gr vector<vpii> #define str string #define mask ...
682
Project_CodeNet
2,020
#pragma GCC optimize("Ofast") #include<bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #define F first #define S second #define int long long #define ll long long //#define int unsigned long long #define pb push_back //#define double long double using namespace std; using namespace __gnu_pbds; typedef tree<...
472
Project_CodeNet
2,020
/* Sarthak Jain */ #include <bits/stdc++.h> using namespace std; #define endl "\n" #define int long long int mod=1e9+7; int min(int a,int b){ return (a<b)?a:b; } int max(int a,int b){ return (a>b)?a:b; } int fp(int a,int b){ if(b==0) return 1; int x=fp(a,b/2); x=(x*x)%mod; if(b&1) x=(x*a)%mod; return x; ...
377
Project_CodeNet
2,020
#include <bits/stdc++.h> #define F first #define S second using namespace std; typedef long long LL; typedef pair<LL, LL> pii; LL solve(LL L, LL R, auto &data, auto &dp, LL idx) { if (~dp[L][R]) return dp[L][R]; if (idx == data.size()) return 0; dp[L][R] = max( solve(L + 1, R, data, dp, idx + 1) + a...
297
Project_CodeNet
2,020
// 解き直し. // https://img.atcoder.jp/abc163/editorial.pdf #include <bits/stdc++.h> using namespace std; using LL = long long; using P = pair<LL, int>; #define repex(i, a, b, c) for(int i = a; i < b; i += c) #define repx(i, a, b) repex(i, a, b, 1) #define rep(i, n) repx(i, 0, n) #define repr(i, a, b) for(int i = a; i >= b...
631
Project_CodeNet
2,020
#include<bits/stdc++.h> using namespace std; typedef long long ll; const ll maxs = 1e5+5; const ll lmaxs = 20; ll mod = 1e9+7; ll oo = 1e15; #define IOS ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); #define pb push_back #define mp make_pair #define ff first #define ss second #define I insert ...
421
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; #define IOS \ ios::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); #define endl "\n" #define int long long const int N = 2005; int n; int a[N], cache[N][N]; pair<int, int> b[N]; int dp(int idx, int i, int j) { if (idx > n) ...
309
Project_CodeNet
2,020
#include <bits/stdc++.h> using namespace std; int main() { int n; cin >> n; vector<pair<long long, long long>> a(n + 1); for (int i = 1; i <= n; ++i) { cin >> a[i].first; a[i].second = i; } sort(a.begin() + 1, a.end(), greater<pair<long long, long long>>()); vector<vector<long long>> dp(n + 1, vector<lon...
314
Project_CodeNet
2,020
#include <bits/stdc++.h> #define rep(i,n) for (ll i = 0; i < n; ++i) using namespace std; using ll = long long; using ull = long long unsigned; using P = pair<ll,ll>; //const int 1001001001; const int NMAX=8; const ll MOD=1000000007; const int dbase=80*160; using namespace std; using ll = long long; int main(){ ll...
322
Project_CodeNet
2,020
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define F first #define S second #define pii pair<int, int> #define eb emplace_back #define all(v) v.begin(), v.end() #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep3(i, l, n) for (int i = l; i < (n); ++i) #define sz(v) (int)v.size() #define...
878
Project_CodeNet
2,020
#include <bits/stdc++.h> typedef long long int ll; typedef std::pair<ll, ll> PLL; #define chmax(a, x) do { a = max(a, x); } while(0) #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) \ for (int i = static_cast<int>(a); i < static_cast<int>(b); ++i) #define rep(...) ...
516
Project_CodeNet
2,020
#include<bits/stdc++.h> #define inf 0x3f3f3f3f3f3f3f3fll using namespace std; typedef long long ll; const int N=2005; int n; ll a[N],b[N],dp[N][N]; bool cmp(int x,int y){return a[x]>a[y];} int main() { memset(dp,-inf,sizeof(dp)); scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%lld",&a[i]),b[i]=i; sort(b+1...
283
Project_CodeNet
2,020
#include <cstdio> #include <cstdlib> #include <cstring> #include <algorithm> #include <iostream> #include <set> #include <map> #include <vector> #include <string> using namespace std; #define LL long long const int dx[4] = {1, -1, 0, 0}; const int dy[4] = {0, 0, 1, -1}; LL mod(LL x, LL md) { return ((x % md) + md)...
2,033
Project_CodeNet
2,020
//#pragma GCC optimize("Ofast,no-stack-protector") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native") #pragma GCC optimize("unroll-loops") /*#pragma GCC optimize("section-anchors") #pragma GCC optimize("profile-values,profile-reorder-functions,tracer") #pragma GCC optimize("vpt") #pragma...
1,386
Project_CodeNet
2,020
function sort(A,l,r,tmp,mid,il,ir)#[l,r) { if(r-l==2) { if(sort_cmp(A[l+1],A[l])) { tmp=A[l]; A[l]=A[l+1]; A[l+1]=tmp; } } else if(r-l>2) { mid=int((l+r)/2); if(sort_cmp(A[mid],A[l])) { tmp=A[mid]; A[mid]=A[l]; A[l]=tmp; } if(sort_cmp(A[r-1],A[mid])) { tmp=A[r-1]; A[r-1]=A...
583
Project_CodeNet
2,020
function main() N=parse(Int,readline()) A=Pair{Int,Int}[] id=0 for a=map(x->parse(Int,x),split(readline())) id+=1 push!(A,a=>id) end sort!(A) reverse!(A) dp=zeros(Int,N+1,N+1) for i=1:N,j=1:i k=N+1-(i-j) dp[j+1,k]=max(dp[j+1,k],dp[j,k]+A[i].first*abs(A[i].second-j)) dp[j,k-1]=max(dp[j,k-1],dp[j,k]+A[...
186
Project_CodeNet
2,020
function solve() n = parse(Int, readline()) a = [parse(Int, x) for x in split(readline())] z = [(a[i], i) for i=1:n] sort!(z, rev=true) dp = zeros(Int, (n+1, n+1)) for s=1:n, i=0:s li = i ri = s-i l = if li > 0 dp[li, ri+1] + z[s][1] * abs(li - z[s][2]) ...
226
Project_CodeNet
2,020
"use strict"; var input=require("fs").readFileSync("/dev/stdin","utf8"); var cin=input.split(/ |\n/),cid=0; function next(a){return a?cin[cid++]:+cin[cid++];} function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);} function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,c...
423
Project_CodeNet
2,020
function main(input) { const inputs = input.split('\n') const N = Number(inputs[0]) const A = inputs[1].split(' ').map(Number) const a = A.map((e,i) => [e, i]).sort((a, b) => { return a[0] < b[0] ? 1: -1 }) // console.log(a) const dp = Array.from(new Array(N+1)).map(e => []) // console....
464
Project_CodeNet
2,020
@file:Suppress("NOTHING_TO_INLINE", "EXPERIMENTAL_FEATURE_WARNING", "OVERRIDE_BY_INLINE") import java.io.PrintWriter import java.util.PriorityQueue import kotlin.math.* import kotlin.random.Random import kotlin.collections.sort as _sort import kotlin.collections.sortDescending as _sortDescending import kotlin.io.print...
1,178
Project_CodeNet
2,020
import kotlin.math.abs import kotlin.math.max class MaxHappinessCalculator( private val n: Int, private val a: Array<Long> ) { private val memo = Array(n + 1) { Array(n + 1) { null as Long?} } private val sorted = (0 until n).sortedByDescending { a[it] } private fun calcFromMemo(l: Int, r: Int): L...
314
Project_CodeNet
2,020
import kotlin.math.abs import kotlin.math.max fun main() { val n = readLine()!!.toInt() val a = readLine()!!.split(' ').map { it.toLong() } val b = a.mapIndexed { i, l -> i to l }.sortedByDescending { it.second }.map { it.first }.toIntArray() val dp = Array(n + 1) { LongArray(n + 1) } for (i in 0 ...
242
Project_CodeNet
2,020
import java.lang.Math.abs fun main() = ABC163E2.main() object ABC163E2 { var equalCount = 0 var hashCount = 0 var calcCount = 0 fun log(message: Any?) { //println(message)// TODO: ←消す } val N: Int val infants: List<Infant> init { N = readInt() val A = readLon...
949
Project_CodeNet
2,020
import java.io.BufferedReader import java.io.InputStream import java.io.InputStreamReader import java.io.PrintWriter import java.util.* fun PrintWriter.solve(sc: FastScanner) { val n = sc.nextInt() val a = Array(n) { sc.nextLong() } val dp = Array(n + 1) { Array(n + 1) { 0L } } val b = (0 until n).map ...
396
Project_CodeNet
2,020
import java.util.* import kotlin.math.abs import kotlin.math.max fun main() { val sc = Scanner(System.`in`) val n = sc.nextInt() val infant = Array(n+1){0 to 0L} val dp = Array(n+1){LongArray(n+1){-1L} } for(i in 0 until n) { infant[i] = i to sc.nextLong() } infant.sortByDescendi...
250
Project_CodeNet
2,020
import kotlin.math.max data class Infant(val a: Long, val origPos: Long) fun main() { val builder = StringBuilder() val n = readInputLine().toInt() val aArr = readInputLine().split(" ").mapIndexed() { index, s -> Infant(s.toLong(), index.toLong() + 1L) }.sortedByDescending { it.a }.toTypedAr...
363
Project_CodeNet
2,020
{-# OPTIONS_GHC -O2 #-} {-# LANGUAGE TypeApplications #-} {-# LANGUAGE Strict #-} {-# LANGUAGE StrictData #-} import qualified Data.Vector.Unboxed as VU import qualified Data.Vector.Unboxed.Mutable as VUM import qualified Data.Vector.Algorithms.Insertion as VA import Data.Array.Unboxed import Data.Array.ST import quali...
409
Project_CodeNet
2,020
{-# LANGUAGE ScopedTypeVariables, BangPatterns, TupleSections, ExplicitForAll, LambdaCase, MultiWayIf, Unsafe, RecordWildCards, FlexibleContexts, CPP, NoMonomorphismRestriction, GADTs, PatternGuards, MagicHash, UnboxedTuples, RankNTypes, EmptyDataDecls, EmptyCase, ViewPatterns, PolyKinds, TypeFamilies, Overlo...
4,607
Project_CodeNet
2,020
import qualified Data.Text as T import qualified Data.Text.IO as T import qualified Data.Text.Read as T import Data.List (sortBy) import Data.Function (on) import qualified Data.Vector.Unboxed as VU main :: IO () main = do n <- unsafeTextToInt <$> T.getLine :: IO Int let f :: [(Int, Int)] -> Int f = VU.max...
336
Project_CodeNet
2,020
{-# OPTIONS_GHC -O2 #-} {-# LANGUAGE BangPatterns, BinaryLiterals, CPP, FlexibleContexts #-} {-# LANGUAGE FlexibleInstances, KindSignatures, LambdaCase, MagicHash #-} {-# LANGUAGE MultiParamTypeClasses, MultiWayIf, OverloadedStrings #-} {-# LANGUAGE RecordWildCards, ScopedTypeVariables, TupleSections #-} ...
1,202
Project_CodeNet
2,020
program test integer(8) :: n,a(3000),b(3000),i,j,k,dp(0:3000,0:3000)=0,left,right,total,max_dp read(*,*) n read(*,*) (a(i),i=1,n) do i=1,n b(i) = i enddo call heapsort_down(n,a(1:n),b(1:n)) ! aが活発度、bが幼児の初期位置(x) do total=1,n do left=0,total-1 right=total-1-left !左詰め dp(left+1,right) = max(dp(left...
615
Project_CodeNet
2,020
program name use,intrinsic :: iso_fortran_env implicit none integer(int64):: n,i,nx,ny, ans integer(int64), allocatable:: a(:), ind(:), dp(:,:) read*, n allocate(a(n), ind(n), dp(-1:n,-1:n)) read*,a(:) ans = 0 do i=1,n ind(i) = i end do call double_sort(a,ind,1_8,n)...
796
Project_CodeNet
2,020
module module_sort implicit none interface sort module procedure int_heap_sort, real_heap_sort end interface contains subroutine int_heap_down(a,node,las) implicit none integer(8) a(*),x integer(8) node,par,ch1,ch2,las par = node ...
867
Project_CodeNet
2,020
module mod_two_dim_merge_sort implicit none integer, private, parameter :: intkind = 4 contains logical function less(a, b) result(res) integer(intkind), intent(in) :: a(:), b(:) res = a(1) > b(1) .or. (a(1) == b(1) .and. a(2) >= b(2)) end subroutine merge_sort(a) integer(intkind), intent(inout) :...
905
Project_CodeNet
2,020
program main implicit none type pairtype integer :: v, k end type pairtype integer(8) :: n, i, j, pos integer, allocatable :: a(:) integer(8), allocatable :: dp(:), dppre(:) type(pairtype), allocatable :: a1(:), a2(:) read *, n allocate (a(n), a1(n), a2(n), dp(0:n), dppre(0:n)) read *, a do i...
586
Project_CodeNet
2,020
let main: () = { let N = nextInt() let A = listOfInt().enumerated().map { ($0.1, $0.0) }.sorted { $0.0 > $1.0 } var dp = Array(N + 2) { _ in Array(N + 2) { _ in -1001001009 } } dp[0][0] = 0 repeate(N) { t in let (cost, n) = A[t] repeate(t + 1) { l in if dp[t][l] >= 0 { ...
572
Project_CodeNet
2,020
import Foundation let N = Int(readLine()!) ?? 0 var array = (readLine()!) .components(separatedBy: " ").map{Int($0) ?? 0 } var array2: [(Int,Int)] = [] for (x, value) in array.enumerated(){ array2.append((x, value)) } array2.sort {$0.1 > $1.1} var status_array = Array(repeating: Array(repeating: 0, count: ...
351
Project_CodeNet
2,020
let n = Int(readLine()!)! let a = readLine()!.split(separator: " ").map { Int($0)! } let sorted = Array(zip(a, Array(0..<n))).sorted(by: { $0.0 > $1.0 }) var dp: [[Int]] = Array( repeating: Array( repeating: 0, count: n + 1 ), count: n + 1 ) dp[0][0] = 0 var answer = 0 for x in 0...n { for y in 0...n...
355
Project_CodeNet
2,020
func readInts() -> [Int64]{ return readLine()!.split(separator: " ").map{Int64($0)!}; } var N = Int(readLine()!)!, ans = Int64(0), A: Array<(Int64, Int)> = Array(repeating: (0,0), count: 2020), dp: Array<Array<Int64>> = Array(repeating: Array(repeating: 0, count: 2020), count: 2020) let a = readInts() for i in 0 .....
355
Project_CodeNet
2,020
open Batteries module EnumL = Enum.Labels module ListL = List.Labels module ArrayL = Array.Labels let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x let dbg1 x = dbg0 x; x let id = identity let (++) n m = List.range n `To m let (++-) n m = if n >= m then List.range n `Downto m else [] let (++^) n m = if n < m then ...
1,035
Project_CodeNet
2,020
Scanf.scanf "%d" (fun n -> let a = Array.init n (fun i -> Scanf.scanf " %d" (fun a -> a, i)) in Array.sort (fun a b -> compare b a) a; let dp = Array.make_matrix (n + 1) n 0 in Array.iteri (fun i (act, pos) -> for j = 0 to i do dp.(i + 1).(j ) <- max dp.(i + 1).(j) (dp.(i).(...
223
Project_CodeNet
2,020
use std::io; pub trait ExRead { fn read_line(&mut self) -> io::Result<String>; fn read_to_string(&mut self) -> io::Result<String>; } impl ExRead for io::StdinLock<'_> { fn read_line(&mut self) -> io::Result<String> { let mut buf = String::new(); io::BufRead::read_line(self, &mut buf).map(|...
705
Project_CodeNet
2,020
use proconio::input; use std::cmp; const INF:i64 = 1e15 as i64; fn main() { input! { n:usize, a:[i64;n], }; let mut dp = vec![vec![-INF;n+1];n+1]; dp[0][0] = 0; let mut pa:Vec<(usize,i64)> = a.into_iter().enumerate().map(|(i,x)|(i,x)).collect(); pa.sort_by_key(|x|{ -x.1...
301
Project_CodeNet
2,020
extern crate proconio; use proconio::input; fn main() { input! { n: usize, a: [i64; n], } let mut a = a.iter().zip(1..=(n as i64)).collect::<Vec<_>>(); a.sort_by(|x, y| y.0.cmp(&x.0)); let mut dp = vec![vec![0; n + 1]; n + 1]; for i in 0..n { for j in 0..n { ...
307
Project_CodeNet
2,020
#[allow(unused_imports)] use std::cmp::Ordering; #[allow(unused_imports)] use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque}; #[allow(unused_imports)] use std::io::{stdin, stdout, BufWriter, Write}; #[allow(unused_imports)] use std::iter::FromIterator; #[allow(unused_macros)] macro_r...
924
Project_CodeNet
2,020
// This code is generated by [cargo-atcoder](https://github.com/tanakh/cargo-atcoder) // Original source code: /* #[allow(unused_imports)] use std::cmp; fn run() { let (r, w) = (std::io::stdin(), std::io::stdout()); let mut sc = IO::new(r.lock(), w.lock()); let n: usize = sc.read(); let a = sc.read_ve...
116,384
Project_CodeNet
2,020
use proconio::{input, fastout}; #[fastout] fn main() { input! { n: usize, ax: [i64; n] } let mut dp = vec![0; n+1]; let mut axi: Vec<_> = ax.iter().enumerate().collect(); axi.sort_by_key(|a| a.1); for i in 0..n { let (pos, &ai) = axi[i]; let pos = pos as i64; ...
200
Project_CodeNet
2,020
fn main() { proconio::input! { n: usize, a: [usize; n], } let mut dp = vec![0;n+1]; let mut b: Vec<_> = (0..n).collect(); b.sort_by_key(|k| a[*k]); for (m,k) in b.into_iter().enumerate() { let f = |i| a[k]*if i>k {i-k} else {k-i}; for i in 0..n-m { dp[...
149
Project_CodeNet
2,020
macro_rules !read_value {($iter :expr ,($($t :tt ) ,*) ) =>{($(read_value !($iter ,$t ) ) ,*) } ;($iter :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($iter ,$t ) ) .collect ::<Vec <_ >>() } ;($iter :expr ,{chars :$base :expr } ) =>{read_value !($iter ,String ) .chars () .map (|c |(c as u8 -$base ...
1,044
Project_CodeNet
2,020
use proconio::input; use std::cmp::Reverse; fn main() { input! { n:usize, a:[usize;n] } let mut v = vec![]; for (i, x) in a.iter().enumerate() { v.push((x, i)); } v.sort_by_key(|&x| Reverse(x.0)); let mut dp = vec![vec![0; n + 2]; n + 2]; for i in 0..n { for j in 0..n { ...
308
Project_CodeNet
2,020
use proconio::input; use std::cmp::max; fn main() { input!{ n: usize, a: [usize; n], } let mut v: Vec<(usize, usize)> = Vec::new(); for (i, j) in a.iter().enumerate() { v.push((j.clone(), i)); } v.sort_by(|x, y| (&y.0).cmp(&x.0)); let mut d = vec![vec![0; n + 1...
317
Project_CodeNet
2,020
#[allow(unused_macros)] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read...
882
Project_CodeNet
2,020
// The main code is at the very bottom. #[allow(unused_imports)] use { lib::byte::ByteChar, std::cell::{Cell, RefCell}, std::cmp::{ self, Ordering::{self, *}, Reverse, }, std::collections::*, std::fmt::{self, Debug, Display, Formatter}, std::io::prelude::*, std::iter::{self, FromIterator}, ...
2,473
Project_CodeNet
2,020
use proconio::{fastout, input}; #[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; #[fastout] fn main() { input! { n: usize, mut a: [isize; n], } let b = a.iter(); let mut c: Vec<(&isize, usize)> = b.enumerate().map(|(a, b)| (b, a)).collect(); ...
370
Project_CodeNet
2,020
use proconio::input; use std::cmp::{max, min}; fn main() { input! { n: usize, aa: [i64; n], }; let mut v = Vec::new(); for (i, a) in aa.iter().enumerate() { v.push((a, i)); } v.sort(); v.reverse(); let mut dp = vec![vec![0; n+1]; n+1]; /* i = 2 (x...
319
Project_CodeNet
2,020
#![allow(unused_imports)] #![allow(non_snake_case)] use std::cmp::*; use std::collections::*; use std::io::Write; #[allow(unused_macros)] macro_rules! debug { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(er...
1,090
Project_CodeNet
2,020
use proconio::input; macro_rules! chmax { ($l: expr, $r: expr) => { $l = std::cmp::max($l, $r); }; } fn main() { input! { n: usize, av: [i64; n], }; let mut pv: Vec<(i64, i64)> = av.iter().enumerate().map(|(i, &a)| (a, i as i64)).collect(); pv.sort_by_key(|(a, i)| (-a,...
346
Project_CodeNet
2,020
use proconio::input; #[allow(unused_imports)] use proconio::marker::{Bytes, Chars, Usize1}; #[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; #[allow(unused_imports)] use std::ops::*; #[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord)] struct Struct; //#[proconi...
450
Project_CodeNet
2,020
#![allow(unused_imports)] #![allow(non_snake_case, unused)] use std::cmp::*; use std::collections::*; use std::ops::*; macro_rules! eprint { ($($t:tt)*) => {{ use ::std::io::Write; let _ = write!(::std::io::stderr(), $($t)*); }}; } macro_rules! eprintln { () => { eprintln!(""); }; ($($t:tt)*) => {{ use ::st...
1,290
Project_CodeNet
2,020
use proconio::*; // fn run() { input! { n: usize, a: [i64; n], } let mut b: Vec<_> = a.into_iter().enumerate().collect(); b.sort_by_key(|p| p.1); let diff = |a: usize, b: usize| -> i64 { (std::cmp::max(a, b) - std::cmp::min(a, b)) as i64 }; let mut dp = vec![0]; ...
255
Project_CodeNet
2,020
use proconio::input; fn main() { input! { n: usize, a: [i64; n], } let mut b: Vec<(i64, usize)> = vec![(0, 0); n]; for (i, &val) in a.iter().enumerate() { b[i] = (val, i); } b.sort(); b.reverse(); let mut dp = vec![vec![0i64; n+1]; n+1]; for i in 0..n { for j in 0..i+1 { dp[i+1][...
277
Project_CodeNet
2,020
use proconio::{fastout, input}; use std::cmp::max; #[fastout] fn main() { input! { n: usize, a: [u64; n] } let mut ans = 0; let mut dp = vec![vec![0; n + 1]; n + 1]; let mut a = a.iter().enumerate().collect::<Vec<_>>(); a.sort_by_key(|x| std::cmp::Reverse(x.1)); let abs = |...
288
Project_CodeNet
2,020
extern crate core; use std::collections::HashMap; use std::io::{self, Read}; #[macro_export] macro_rules! input { ($s:expr=>$($t:tt)*) => { let mut lines=$s.split("\n"); $( line_parse!(lines,$t); )* }; } macro_rules! line_parse { ($lines:expr,($($name:ident:$t:tt)*)) => { let mut line=$lin...
1,231
Project_CodeNet
2,020
// https://atcoder.jp/contests/abc163/tasks/abc163_e // #![allow(unused_imports)] use std::io::*; use std::io::Write; use std::fmt::*; use std::str::*; use std::cmp::*; use std::collections::*; // Input macros. // Original by tanakh: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 #[allow(unused_macros)] macro_rul...
1,284
Project_CodeNet
2,020
use std::cmp::max; use std::io::*; fn main() { let mut s: String = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut itr = s.trim().split_whitespace(); let n: usize = itr.next().unwrap().parse().unwrap(); let mut a = Vec::new(); for i in 0..n { let b: i64 = itr.next()...
314
Project_CodeNet
2,020
#[macro_use] mod input_mcr { // ref: tanakh <https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8> // diff: using Parser #[macro_export(local_inner_macros)] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut parser = Parser::from_str($s); input_inner!{parser, $($r)*} ...
1,884
Project_CodeNet
2,020
#[allow(unused_imports)] use std::char::from_digit; #[allow(unused_imports)] use std::cmp::{max, min}; #[allow(unused_imports)] use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque}; #[allow(unused_imports)] use std::fs::File; #[allow(unused_imports)] use std::io::prelude::*; #[allow(unused...
1,421
Project_CodeNet
2,020
macro_rules! input { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input!{$next $($r)*} }; } macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ...
765
Project_CodeNet
2,020
// This code is generated by [cargo-atcoder](https://github.com/tanakh/cargo-atcoder) // Original source code: /* use proconio::input; #[allow(unused_imports)] use proconio::marker::*; #[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; #[allow(unused_imports)] use std::f64::cons...
245,196
Project_CodeNet
2,020
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufRead...
850
Project_CodeNet
2,020
#![allow(dead_code, unused_imports, deprecated)] use std::cmp::{max, min, Reverse}; use proconio::input; use proconio::marker::*; use proconio::fastout; const INF: usize = 1_000_000_007; #[fastout] fn solve() { input!{ n: usize, a: [i64; n], }; let mut a = a .iter() .enumerate() .collect::...
441
Project_CodeNet
2,020
#[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; use std::io::{Write, BufWriter}; // https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 macro_rules! input { ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufRea...
1,405
Project_CodeNet
2,020
use std::cmp::max; use proconio::input; fn main() { input! { n: usize, a: [u64; n], } let mut a: Vec<(u64, usize)> = a.iter().copied().enumerate().map(|(i, x)| (x, i)).collect(); a.sort(); a.reverse(); let a = a; let mut solve = Solve { n, a, }; sol...
421
Project_CodeNet
2,020
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)] use { proconio::{marker::*, *}, std::{cmp::*, collections::*, mem::*}, }; #[fastout] fn main() { input! { n:usize, a:[i64;n], } let mut ai = vec![(0, 0); n]; for (i, &x) in a.iter().enumerate() { ai[i] = (x, i...
355
Project_CodeNet
2,020
use proconio::{input,fastout}; use std::cmp::{max, min}; #[fastout] fn main(){ input!{ n: usize, a: [i64;n] } let mut b: Vec<_> = a.into_iter().enumerate().collect(); b.sort_by_key(|p| p.1); let diff = |a:usize, b:usize| -> i64 { (max(a, b) - min(a, b)) as i64 }; let ...
242
Project_CodeNet
2,020
use std::cmp::{max, Reverse}; use std::collections::VecDeque; fn main() { let (r, w) = (std::io::stdin(), std::io::stdout()); let mut sc = IO::new(r.lock(), w.lock()); let n: usize = sc.read(); let mut a = vec![]; for i in 0..n { let v: i64 = sc.read(); a.push((v, i)); } a....
701
Project_CodeNet
2,020
use proconio::{fastout, input}; #[fastout] fn main() { input! { n: usize, a: [u64; n], } let mut dp = vec![vec![0 as u64; n + 1]; n + 1]; let mut v = vec![0; n]; for i in 0..n { v[i] = i; } let v = v.as_mut_slice(); v.sort_by(|&i, &j| { if a[i] != a[j] { ...
367
Project_CodeNet
2,020
pub struct Scanner { line: Vec<String>, idx: usize, } #[allow(dead_code)] impl Scanner { fn new() -> Scanner { return Scanner { line: vec![], idx: 0, }; } fn next<T: std::str::FromStr>(&mut self) -> T { if self.idx == self.line.len() { let...
580
Project_CodeNet
2,020
#![allow(unused_imports)] use itertools::Itertools; use proconio::{input, marker::*}; use std::cmp::*; use std::collections::*; use superslice::*; fn main() { input! { n: usize, a: [i64; n], } let mut a = a.iter().zip(0..n).collect::<Vec<_>>(); a.sort(); a.reverse(); let mut d...
288
Project_CodeNet
2,020
// This code is generated by [cargo-atcoder](https://github.com/tanakh/cargo-atcoder) // Original source code: /* #![allow(unused_imports)] #![allow(bare_trait_objects)] // for compatibility with 1.15.1 use std::cmp::Ordering::{self, Greater, Less}; use std::cmp::{max, min}; use std::collections::{BTreeMap, BTreeSet, B...
119,736
Project_CodeNet
2,020
use proconio::input; use std::cmp::*; fn main() { input! { n: usize, a: [i64;n] } let mut ai: Vec<(i64, i64)> = a.iter().enumerate().map(|(i, &a)| (a, i as i64)).collect(); ai.sort(); ai.reverse(); // 降順に並んだ。 // println!("{:?}", ai); let mut dp = vec![vec![0; n + 1]; n ...
295
Project_CodeNet
2,020
use std::cmp; use std::collections::BinaryHeap; use std::collections::HashMap; use std::collections::HashSet; use std::collections::VecDeque; use std::io::Read; use std::usize::MAX; macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };inp...
978
Project_CodeNet
2,020
// This code is generated by [cargo-atcoder](https://github.com/tanakh/cargo-atcoder) // Original source code: /* use competitive::prelude::*; fn main() { input! { n: usize, a: [i64; n], } let a = a .into_iter() .enumerate() .map(|r| (-r.1, r.0)) .sorted() ...
112,932
Project_CodeNet
2,020
#[allow(dead_code)] fn is_whitespace(c: &char) -> bool { c.is_whitespace() } #[allow(dead_code)] fn is_eol(c: &char) -> bool { ['\r', '\n'].contains(c) } #[allow(unused_macros)] macro_rules! input { ($var:ident, $($r:tt)*) => { input_inner!{$var, $($r)*} }; ($($r:tt)*) => { let st...
991
Project_CodeNet
2,020
//! Framework <https://github.com/vain0x/procon> #![allow(non_snake_case)] #![allow(unused_imports)] use std::collections::*; pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // ' impl Scan { fn new() -> Self { let mut buf = String::new(); let read_line = move || { std::io::s...
556
Project_CodeNet
2,020
#![allow(unused_imports)]pub mod pcl{pub mod macros{#[macro_export]macro_rules!rtl{(@ lhs($($ lhs:tt)*)@ rest+=$($ rest:tt)*)=>{rtl!(@ op+=@ lhs($($ lhs)*)@ rhs()@ rest $($ rest)*)};(@ lhs($($ lhs:tt)*)@ rest-=$($ rest:tt)*)=>{rtl!(@ op-=@ lhs($($ lhs)*)@ rhs()@ rest $($ rest)*)};(@ lhs($($ lhs:tt)*)@ rest*=$($ rest:tt...
3,479
Project_CodeNet
2,020
#[allow(unused_macros)] macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read...
10,919
Project_CodeNet
2,020
use proconio::{input, fastout}; use std::cmp::max; use num::abs; #[fastout] fn main() { input! { n: usize, aaa: [usize; n], } let mut aaa_with_idx: Vec<(usize, &usize)> = aaa.iter().enumerate().collect(); aaa_with_idx.sort_by(|a, b| { a.1.cmp(b.1) }); aaa_with_idx.reverse(); ...
283
Project_CodeNet
2,020
#![allow(unused_imports)] use std::cmp::*; use std::collections::*; use itertools::Itertools; use proconio::{input, marker::*}; use superslice::*; use rustc_hash::FxHashSet; fn main() { input! { n: usize, ai: [i64; n], } let mut ai: Vec<_> = ai.into_iter().enumerate().map(|(i,a)| (a, i as i6...
327
Project_CodeNet
2,020
use proconio::input; fn main() { input! { n: usize, a: [isize; n], } let mut dp = vec![vec![0; n + 1]; n + 1]; for (i, &arg) in arg_sort_descending(&a).iter().enumerate() { for l in 0..=i { let r = n - (i - l) - 1; dp[i + 1][l + 1] = dp[i ...
260
Project_CodeNet
2,020
use proconio::input; #[allow(unused_imports)] use proconio::marker::*; fn main() { input! { n: usize, a: [i64; n], } let mut a = a .iter() .enumerate() .map(|(i, x)| (i as i64, *x)) .collect::<Vec<_>>(); a.sort_by_key(|x| -x.1); let mut dp = vec![vec...
270
Project_CodeNet
2,020
use std::io::{self, BufRead}; use std::cmp::max; fn abs(x: usize, y: usize) -> usize { if x < y { y - x } else { x - y } } fn main() { let stdin = io::stdin(); let mut lines = stdin.lock().lines(); let line = lines.next().unwrap().unwrap(); let n: usize = line.parse().unwrap(); let line = lines.next().unw...
360