結果
問題 | No.2284 Assembly |
ユーザー | otoshigo |
提出日時 | 2023-04-28 23:53:30 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 990 bytes |
コンパイル時間 | 839 ms |
コンパイル使用メモリ | 84,432 KB |
実行使用メモリ | 8,704 KB |
最終ジャッジ日時 | 2024-04-29 00:51:57 |
合計ジャッジ時間 | 2,291 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,944 KB |
testcase_04 | WA | - |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,940 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 39 ms
8,576 KB |
ソースコード
#include<iostream> #include<vector> #include<algorithm> #include<deque> using namespace std; using ll=long long; #define rep(i,n) for(int i=0;i<n;i++) #define rrep(i,n) for(int i=(n)-1;i>=0;i--) #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int n; cin>>n; vector<ll>A(n),B(n); deque<int>dq; rep(i,n){ cin>>A[i]>>B[i]; } rrep(i,n){ if(dq.empty())dq.push_back(i); else{ int f=dq.front(),b=dq.back(); if(A[f]*B[i]-A[i]*B[f]>=A[i]*B[b]-A[b]*B[i])dq.push_front(i); else dq.push_back(i); } } ll ans=0; vector<ll>S(n+1); rep(i,n)S[i+1]=S[i]+B[dq[i]]; rrep(i,n)ans+=A[dq[i]]*S[i]; cout<<ans<<"\n"; }