結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 131 ms
20,480 KB
testcase_05 AC 132 ms
20,352 KB
testcase_06 AC 60 ms
7,808 KB
testcase_07 AC 61 ms
7,808 KB
testcase_08 AC 60 ms
7,808 KB
testcase_09 AC 69 ms
7,808 KB
testcase_10 AC 64 ms
7,936 KB
testcase_11 AC 81 ms
10,880 KB
testcase_12 AC 80 ms
10,880 KB
testcase_13 AC 82 ms
10,880 KB
testcase_14 AC 80 ms
10,880 KB
testcase_15 AC 82 ms
10,880 KB
testcase_16 AC 117 ms
19,456 KB
testcase_17 AC 117 ms
19,584 KB
testcase_18 AC 120 ms
19,840 KB
testcase_19 AC 80 ms
14,336 KB
testcase_20 AC 111 ms
18,688 KB
testcase_21 AC 126 ms
18,944 KB
testcase_22 AC 75 ms
13,184 KB
testcase_23 AC 93 ms
17,024 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