結果
| 問題 |
No.1687 What the Heck?
|
| コンテスト | |
| ユーザー |
noya2
|
| 提出日時 | 2021-07-18 18:43:19 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 855 bytes |
| コンパイル時間 | 216 ms |
| コンパイル使用メモリ | 25,088 KB |
| 最終ジャッジ日時 | 2025-01-23 03:10:50 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:1:10: fatal error: testlib.h: No such file or directory
1 | #include "testlib.h"
| ^~~~~~~~~~~
compilation terminated.
ソースコード
#include "testlib.h"
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
int main(){
registerValidation();
ll n = inf.readInt(1,200000,"n");
inf.readEoln();
vector<pll> ar(n);
for (int i = 0; i < n; i++){
ll c = inf.readInt(1,n,"c");
ar[i] = pll(-c,ll(i+1));
if (i == n-1) inf.readEoln();
else inf.readSpace();
}
sort(ar.begin(),ar.end());
if (n == 1){
assert(ar[0].first == -1);
cout << 0 << endl;
inf.readEof();
return 0;
}
ll f = n * (n + 1) / 2;
ll ima = 2 * ar[0].second;
ll mi = ima;
for (int i = 0; i < n-1; i++){
ima = ima - ar[i].second + 2 * ar[i+1].second;
if (i == n-2) ima -= ar[i+1].second;
mi = min(mi,ima);
}
for (int i = 0; i < n; i++){
assert(n+ar[i].first == i);
}
cout << f - mi << endl;
inf.readEof();
return 0;
}
noya2