Your browser is not supported
telegram.com cannot provide a good user experience to your browser. To use this site and continue to benefit from our journalism and site features, please upgrade to the latest version of 使用Olymp Trade創建交易賬戶 Chrome, Edge, Firefox or Safari.
Codeforces Round #765 (Div. 2) B. Elementary Particles
Evil_boy__ 于 2022-01-13 15:05:33 发布 325 收藏 1
Martians are actively engaged in interplanetary trade. Olymp City, the Martian city known for its spaceport, has become a place where goods from all the corners of our Galaxy come. To deliver even more freight from faraway planets, Martians need fast spaceships.
A group of scientists conducts 使用Olymp Trade創建交易賬戶 experiments to build a fast engine for the new spaceship. In the current experiment, there are nn elementary particles, the ii-th of them has type aiai.
Denote a subsegment of the particle sequence (a1,a2,…,ana1,a2,…,an) as a sequence (al,al+1,…,aral,al+1,…,ar) for some left bound ll and right bound rr (1≤l≤r≤n1≤l≤r≤n). For instance, the sequence (1 4 2 8 5 7)(1 4 2 8 5 7) for l=2l=2 and r=4r=4 has the sequence (4 2 8)(4 2 8) as a subsegment. Two subsegments are considered different if at least one bound of those subsegments differs.
Note that the subsegments can be equal as sequences but still considered different. For example, consider the sequence (1 1 1 1 1)(1 1 1 1 1) and two of its subsegments: one with l=1l=1 and r=3r=3 and another with l=2l=2 and r=4r=4. Both subsegments are equal to (1 1 1)(1 1 1), but still considered different, 使用Olymp Trade創建交易賬戶 as their left and right bounds differ.使用Olymp Trade創建交易賬戶
The scientists want to conduct a reaction to get two different subsegments of the same length. Denote this length kk. The resulting pair of subsegments must be harmonious, i. e. for some ii (1≤i≤k1≤i≤k) it must be true that the types of particles on the ii-th position are the same for these two subsegments. For example, the pair (1 7 3)(1 7 3) and (4 7 8)(4 7 8) is harmonious, as both subsegments have 77 on the second position. The pair (1 2 3)(1 2 3) and (3 1 2)(3 1 2) is not harmonious.
The longer are harmonious subsegments, the more chances for the scientists to design a fast engine. So, they asked you to calculate the maximal possible length of harmonious pair made of different subsegments.
The first line contains an integer tt (1≤t≤1001≤t≤100) — the number of test cases. The following are descriptions of the test cases.
The first line contains an integer nn (2≤n≤1500002≤n≤150000) — the amount of elementary particles in the sequence.
The second line contains nn integers aiai (1≤ai≤1500001≤ai≤150000) — types of elementary particles.
It is guaranteed that the sum of nn over all test cases does not exceed 3⋅1053⋅105.
For each test, print a single integer, maximal possible length of harmonious pair made of different subsegments. If such pair does not exist, print −1−1 instead.
The first test case is shown on the picture below:
As you can see from it, you may choose the subsegments (2 1 3 4)(2 1 3 4) and (3 1 5 2)(3 1 5 2), which are a harmonious pair. Their length is equal to 44, so the answer is 44.
In the second test case, you need to take two subsegments: one with l=1l=1 and r=5r=5, and one with l=2l=2 and r=6r=6. It's not hard to observe that these segments are a harmonious pair and considered different even though they are both equal to (1 1 1 1 1)(1 1 1 1 1).
In the third test case, you cannot make a harmonious pair, so the answer is −1−1.
思路:用结构体存下这个数组的值和下边,然后快排(数值从小到大,下标从小到大),遍历一遍数组,如果当前和前一位值相同就max(使用Olymp Trade創建交易賬戶 答案,i + n - l);
Your browser is not supported
telegram.com cannot provide a good user experience to your browser. To use this site and continue to benefit from our journalism and site features, please upgrade to the latest version of Chrome, Edge, Firefox or Safari.
在埃及通过银行卡(Visa、Mastercard、中国银联)、网上银行、电子支付(Neteller、Skrill、Perfect Money、WebMoney、Advcash、Fawry)和加密货币在 Olymp Trade 中存钱
点击“使用Olymp Trade創建交易賬戶 付款”按钮。
进入存款页面。
选择一种付款方式并输入您的存款金额。 最低存款金额仅为 10 美元/10 欧元。 但是,不同国家/地区可能会有所不同。
系统可能会为您提供存款红利,利用红利增加存款。
如果您使用银行卡充值,您可以存储您的卡详细信息,以便将来进行一键存款。
点击“支付. ”蓝色按钮。
输入卡数据并点击“支付”。
现在您可以使用真实账户进行交易。
使用移动设备存款
点击“存款”按钮。
选择一种付款方式并输入您的存款金额。 最低存款金额仅为 10 美元/10 欧元。 但是,不同国家/地区可能会有所不同。
系统可能会为您提供存款红利,利用红利增加存款。
如果您使用银行卡充值,您可以存储您的卡详细信息,以便将来进行一键存款。
点击“支付. ”。
输入卡数据,然后单击“支付”绿色按钮。
现在您可以使用真实账户进行交易。
常见问题 (FAQ)使用Olymp Trade創建交易賬戶
资金何时到账?
资金通常会很快存入交易账户,但有时可能需要 2 到 5 个工作日(取决于您的支付提供商)。
如果在您入金后资金没有立即存入您的账户,请等待 1小时。 如果 1 小时后仍然没有钱,请等待并再次检查。
我转移了资金,但没有记入我的账户
你们收取经纪账户费用吗?
如果客户没有在真实账户中进行交易或/并且没有存入/提取资金,则每月将向其账户收取 10 美元(十美元或等值的账户货币)费用。 此规则载于非交易法规和 KYC/AML 政策中。