結果
| 問題 | No.818 Dinner time |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2026-07-22 15:33:10 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 743 bytes |
| 記録 | |
| コンパイル時間 | 1,002 ms |
| コンパイル使用メモリ | 179,456 KB |
| 実行使用メモリ | 5,888 KB |
| 最終ジャッジ日時 | 2026-07-22 15:33:13 |
| 合計ジャッジ時間 | 2,594 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 4 |
| other | WA * 29 |
ソースコード
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e5+5;
const ll inf = -1145141919810;
int n,m;
ll a[N],b[N],maxn = inf,tmp,ans,cnt;
bool ok[N];
int main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
freopen("remake.in","r",stdin);
freopen("remake.out","w",stdout);
cin>>n>>m;
tmp = 0;maxn = inf;
for(int i=1;i<=n;i++){
cin>>a[i]>>b[i];
if(a[i]>0) tmp+=(m-1)*a[i];
else if(a[i]<0&&b[i]>=a[i]*(m-1)){
tmp+=b[i];
ok[i] = true;
}
else if(a[i]<0&&b[i]<a[i]*(m-1)) tmp+=(m-1)*a[i];
if(maxn<tmp){
cnt = i;
maxn = tmp;
}
// cout<<tmp<<"???"<<ans<<'\n';
}
ans = maxn;
for(int i=1;i<=n;i++){
if(ok[i]&&i<=cnt) continue;
ans+=max(a[i],b[i]);
}
cout<<ans;
return 0;
}
vjudge1