結果
| 問題 |
No.2284 Assembly
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2023-05-19 18:11:08 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 40 ms / 2,000 ms |
| コード長 | 786 bytes |
| コンパイル時間 | 465 ms |
| コンパイル使用メモリ | 41,796 KB |
| 実行使用メモリ | 7,880 KB |
| 最終ジャッジ日時 | 2024-12-18 00:25:54 |
| 合計ジャッジ時間 | 2,345 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 |
ソースコード
/* -*- coding: utf-8 -*-
*
* 2284.cc: No.2284 Assembly - yukicoder
*/
#include<cstdio>
#include<algorithm>
using namespace std;
/* constant */
const int MAX_N = 200000;
/* typedef */
typedef long long ll;
/* global variables */
int as[MAX_N], bs[MAX_N];
ll ass[MAX_N + 1], bss[MAX_N + 1];
/* subroutines */
/* main */
int main() {
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) scanf("%d%d", as + i, bs + i);
for (int i = 0; i < n; i++)
ass[i + 1] = ass[i] + as[i], bss[i + 1] = bss[i] + bs[i];
ll sum = 0, fb = 0, ta = 0;
for (int i = 0; i < n; i++) {
sum += fb * as[i] + ta * bs[i];
if ((ass[n] - ass[i]) * bs[i] >= (bss[n] - bss[i]) * as[i])
fb += bs[i];
else
ta += as[i];
}
printf("%lld\n", sum);
return 0;
}
tnakao0123