結果

問題 No.2566 美しい整数列
ユーザー Fuadul hasanFuadul hasan
提出日時 2024-01-26 18:44:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 142 ms / 2,000 ms
コード長 4,939 bytes
コンパイル時間 3,311 ms
コンパイル使用メモリ 238,692 KB
実行使用メモリ 20,608 KB
最終ジャッジ日時 2024-01-26 18:44:40
合計ジャッジ時間 8,827 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 139 ms
20,608 KB
testcase_05 AC 141 ms
20,608 KB
testcase_06 AC 67 ms
8,064 KB
testcase_07 AC 68 ms
8,064 KB
testcase_08 AC 66 ms
8,064 KB
testcase_09 AC 70 ms
8,064 KB
testcase_10 AC 69 ms
8,064 KB
testcase_11 AC 90 ms
11,136 KB
testcase_12 AC 92 ms
11,136 KB
testcase_13 AC 93 ms
11,136 KB
testcase_14 AC 92 ms
11,136 KB
testcase_15 AC 92 ms
11,136 KB
testcase_16 AC 136 ms
19,712 KB
testcase_17 AC 136 ms
19,968 KB
testcase_18 AC 142 ms
20,096 KB
testcase_19 AC 92 ms
14,464 KB
testcase_20 AC 123 ms
18,816 KB
testcase_21 AC 137 ms
19,200 KB
testcase_22 AC 88 ms
13,440 KB
testcase_23 AC 102 ms
17,280 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// Author: Fuadul Hasan(fuadul202@gmail.com)
// Dhaka,Bangladesh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("avx2")

using namespace std;
using namespace __gnu_pbds;

//debug..........
#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;while (getline(ss, x, c))v.emplace_back(x); return move(v);} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}

//............ignore it..................//
#define F first
#define S second
#define Pi atan(1)*4
#define mp make_pair
#define pb  push_back
const int M    = 1e9 + 7;
#define TN   typename
#define ld  long double
#define int  long long int
#define happy cin.tie(0);
#define point(x) cout<<fixed<<setprecision(x)
int length(string s){return (int)s.size();}
#define mem(a)  memset(a , 0 ,sizeof a)
#define memn(a) memset(a , -1 ,sizeof a)
#define coding ios::sync_with_stdio(false);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;

// typedef tree <pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update > ordered_set;
typedef tree <int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update > ordered_multiset;
template <class T>using ordered_set = tree<T,null_type,less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*
Note :  There is a problem with erase() function in ordered_multiset (for less_equal<int> tag).
        lower_bound() works as upper_bound() and vice-versa.
        Be careful to use.
        i) find_by_order(k) : kth smallest element counting from 0 .
        ii) order_of_key(k) : number of elements strictly smaller than k.
*/

int length(long long x){int l = 0;for(long long i=x;i;i/=10)l++;return l;}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1}; 

#define rep(i,b,e)  for(__typeof(e) i = (b) ; i != (e + 1) - 2 * ((b) > (e))  ; i += 1 - 2 * ((b) > (e)))
long long Inv_pow(long long a,long long n){int res = 1;while(n){if(n&1) res = ((res%M)*(a%M))%M;a = ((a%M)*(a%M))%M;n>>=1;}return res%M;}
long long Lcm(long long a,long long b){return (((a)*(b)))/__gcd(a,b);}

template<class T> bool remin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool remax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

template<typename T1, typename T2> // cin >> pair<T1, T2>
istream& operator>>(istream &istream, pair<T1, T2> &p) { return (istream >> p.first >> p.second); }
template<typename T> // cin >> vector<T>
istream& operator>>(istream &istream, vector<T> &v) { for (auto &it : v) cin >> it; return istream; }
template<typename T1, typename T2> // cout << pair<T1, T2>
ostream& operator<<(ostream &ostream, const pair<T1, T2> &p) { return (ostream << p.first << " " << p.second); }
template<typename T> // cout << vector<T>
ostream& operator<<(ostream &ostream, const vector<T> &c) { for (auto &it : c) cout << it << " "; return ostream; }

inline int add(int a, int b, int mod) {a += b ; return a >= mod ? a - mod : a ;}
inline int sub(int a, int b, int mod) {a -= b ; return a < 0 ? a + mod : a ;}
inline int mul(int a, int b, int mod) {return (int)a * b % mod ;}
inline int sumv(vector<int>&a){int sum = 0;for(auto i: a)sum += i;return sum;}

#define Test cout<<"Case "<<tc++<<": ";
#define Test_hash cout<<"Case #"<<tc++<<": ";
int tc = 1;

#define   pr     pair<int, int> 
#define   vpr     vector<pr> 
#define   vi       std::vector<int>
#define   vll      std::vector<ll>
#define   all(n) n.begin(),n.end()

#define Yes cout << "Yes\n"
#define No cout << "No\n"
#define YES cout << "YES\n"
#define NO cout << "NO\n"

const int Inf           = (int)2e9 + 5;
const int Lnf           = 2e18 + 5;
const int N             = 1429431 + 20;
const int maxN            = 1e6 + 5;
// #define endl '\n'

// int
int32_t solve() 
{
    
    //Test

    int n,m;
    cin>>n>>m;

    vector<int> a(n) , b(m) , c(n);
    cin>>a>>b>>c;

    int s = 0;
    for(int i=0;i+1<n;i++){
        s += b[i%m];
        a[i+1] -= s;
    }

    int ret = Inf;

    auto S = accumulate(c.begin(), c.end(), 0LL);

    map<int,int> xs;

    for(int i=0;i<n;i++){
        xs[a[i]] += c[i];
    }

    int sub = -Inf;

    for(auto p: xs){
        sub = max(sub, p.second);
    }
    ret = S - sub;

    cout<<ret<<endl;



    return 0;
    //error();
}

// int
int32_t main(){

    happy coding
    int test = 1;
    // freopen("in.txt" , "r" , stdin);
    // freopen("out.txt" , "w" , stdout);
    //cin>>test;
    while (test--)solve();return 0;
}

/*
I know who....
*/
0