結果
問題 | No.989 N×Mマス計算(K以上) |
ユーザー |
![]() |
提出日時 | 2020-02-14 22:03:11 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 29 ms / 2,000 ms |
コード長 | 2,673 bytes |
コンパイル時間 | 1,677 ms |
コンパイル使用メモリ | 174,320 KB |
実行使用メモリ | 5,640 KB |
最終ジャッジ日時 | 2024-10-06 11:51:28 |
合計ジャッジ時間 | 2,727 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 18 |
ソースコード
#include <bits/stdc++.h>using namespace std;//repetition#define FOR(i,a,b) for(ll i=(a);i<(b);++i)#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)//container util#define all(x) (x).begin(),(x).end()//typedeftypedef long long ll;typedef vector<int> VI;typedef vector<VI> VVI;typedef vector<ll> VLL;typedef vector<VLL> VVLL;typedef vector<string> VS;typedef pair<int, int> PII;typedef pair<ll, ll> PLL;//const value//const ll MOD = 1e9 + 7;//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};//conversioninline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}// Mod intconst int mod = 1000000007;struct mint {ll x;mint():x(0){}mint(ll x):x((x%mod+mod)%mod){}// mint(ll x):x(x){}mint& fix() { x = (x%mod+mod)%mod; return *this;}mint operator-() const { return mint(0) - *this;}mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}mint operator+(const mint& a)const{ return mint(*this) += a;}mint operator-(const mint& a)const{ return mint(*this) -= a;}mint operator*(const mint& a)const{ return mint(*this) *= a;}bool operator<(const mint& a)const{ return x < a.x;}bool operator==(const mint& a)const{ return x == a.x;}};istream& operator>>(istream&i,mint&a){i>>a.x;return i;}ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}typedef vector<mint> vm;typedef vector<vm> vvm;//int main(){ios::sync_with_stdio(false);cin.tie(0);char cmd;int n,m;ll k;cin >> m >> n >> k;cin >> cmd;VLL x(n);VLL y(m);rep(i,n) cin >> x[i];rep(i,m) cin >> y[i];sort(all(x));sort(all(y));if(cmd == '+'){ll ans = 0;VLL yy;yy.push_back(-1e12);rep(i,m) yy.push_back(y[i]);rep(i,n) {ll less = k-x[i];if(less <= 0) {ans += m;continue;}ll outCnt = (lower_bound(all(yy),less) - yy.begin()) - 1;ans += m - outCnt ;}cout << ans << endl;}else{ll ans = 0;VLL yy;yy.push_back(-1e12);rep(i,m) yy.push_back(y[i]);rep(i,n) {if(x[i] >= k) {ans += m;continue;}ll less = (k+x[i]-1)/x[i];ll outCnt = (lower_bound(all(yy),less) - yy.begin()) - 1;ans += m - outCnt ;}cout << ans << endl;}return 0;}