結果
| 問題 | No.818 Dinner time |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2026-07-22 15:36:22 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 793 bytes |
| 記録 | |
| コンパイル時間 | 942 ms |
| コンパイル使用メモリ | 179,992 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-07-22 15:36:26 |
| 合計ジャッジ時間 | 3,116 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 25 WA * 4 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
const int _ = 1e5 + 9;
long long n, m;
long long a[_], b[_], flg[_];
long long tot, ans1, ans2, pos;
int main()
{
//freopen("remake.in", "r", stdin);
//freopen("remake.out", "w", stdout);
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
for(int i = 1;i <= n;i++)
{
cin >> a[i] >> b[i];
if(a[i] > 0)
tot += (m - 1) * a[i];
else if(b[i] >= (m - 1) * a[i])
tot += b[i], flg[i] = 1;
else
tot += (m - 1) * a[i];
if(tot > ans1)
ans1 = tot, pos = i;
}
for(int i = pos + 1;i <= n;i++)
flg[i] = 0;
tot = 0;
for(int i = 1;i <= n;i++)
{
if(a[i] > 0)
tot += max(a[i], b[i]);
else if(flg[i])
tot += 0;
else
tot += max(a[i], b[i]);
ans2 = max(ans2, tot);
}
cout << ans1 + ans2;
return 0;
}
vjudge1