結果

問題 No.1347 HS Railway
ユーザー 👑 PCTprobabilityPCTprobability
提出日時 2021-01-15 23:20:20
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 3,027 bytes
コンパイル時間 3,188 ms
コンパイル使用メモリ 164,864 KB
実行使用メモリ 17,568 KB
最終ジャッジ日時 2024-05-05 01:15:27
合計ジャッジ時間 10,865 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,884 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 3 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 408 ms
9,728 KB
testcase_13 AC 768 ms
7,040 KB
testcase_14 AC 88 ms
5,504 KB
testcase_15 AC 18 ms
7,424 KB
testcase_16 AC 729 ms
8,704 KB
testcase_17 AC 69 ms
5,376 KB
testcase_18 TLE -
testcase_19 TLE -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define all(s) (s).begin(),(s).end()
#define vcin(n) for(ll i=0;i<ll(n.size());i++) cin>>n[i]
#define rever(vec) reverse(vec.begin(), vec.end())
#define sor(vec) sort(vec.begin(), vec.end())
#define fi first
#define se second
const ll mod = 998244353;
//const ll mod = 1000000007;
const ll inf = 2000000000000000000ll;
static const long double pi = 3.141592653589793;
template<class T,class U> void chmax(T& t,const U& u){if(t<u) t=u;}
template<class T,class U> void chmin(T& t,const U& u){if(t>u) t=u;}
ll modPow(ll a, ll n, ll mod) { ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1; } return ret; }
int main() {
  /* mod は 1e9+7 */
  ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
  cout<< fixed << setprecision(10);
  ll n;
  cin>>n;
  ll a[5][n-1];
  ll f[5][n];
  vector<ll> l(5),r(5);
  for(int i=0;i<5;i++){
    cin>>l[i]>>r[i];
    l[i]--;
    r[i]--;
    for(int j=l[i];j<=r[i]-1;j++){
      cin>>a[i][j];
      f[i][j]=0;
    }
    f[i][n-1]=0;
  }
  for(int i=0;i<5;i++){
    for(int j=1;j<n;j++){
      f[i][j]=f[i][j-1]+a[i][j-1];
    }
  }
  ll m;
  cin>>m;
  vector<vector<ll>> s(5);
  map<ll,ll> u;
  for(int i=0;i<m;i++){
    ll b,si;
    cin>>b>>si;
    b--;
    assert(u[si]==0);
    u[si]++;
    s[b].push_back(si);
  }
  ll ans=0;
  for(int i=0;i<5;i++){
    for(int j=i+1;j<5;j++){
      if(l[i]>r[j]||l[j]>r[i]){
        continue;
      }
      if(l[i]<=l[j]&&r[j]<=r[i]){
        for(int k=0;k<int(s[j].size());k++){
          for(int e=0;e<int(s[i].size());e++){
            ll a=s[i][e]+f[i][l[j]]-f[i][l[i]];
          ll b=s[j][k];
          ll c=f[j][r[j]]-f[j][l[j]];
          ll d=f[i][r[j]]-f[i][l[j]];
            if(b<=a&&(b+c-d)>=a){
              ans++;
            }
          }
        }
      }
      else if(l[j]<=l[i]&&r[i]<=r[j]){
        for(int k=0;k<int(s[j].size());k++){
          for(int e=0;e<int(s[i].size());e++){
            ll a=s[i][e];
          ll b=s[j][k]+f[j][l[i]]-f[j][l[j]];
          ll c=f[j][r[i]]-f[j][l[i]];
          ll d=f[i][r[i]]-f[i][l[i]];
            if(a>=b&&(b+c-d)>=a){
              ans++;
            }
          }
        }
      }
      else if(l[i]<=l[j]){
        for(int k=0;k<int(s[j].size());k++){
          for(int e=0;e<int(s[i].size());e++){
            ll a=s[i][e]+f[i][l[j]]-f[i][l[i]];
          ll b=s[j][k];
          ll c=f[j][r[i]]-f[j][l[j]];
          ll d=f[i][r[i]]-f[i][l[j]];
            if(a>=b&&(b+c-d)>=a){
              ans++;
            }
          }
        }
      }
      else if(l[j]<=l[i]){
        for(int k=0;k<int(s[j].size());k++){
          for(int e=0;e<int(s[i].size());e++){
            ll a=s[i][e];
          ll b=s[j][k]+f[j][l[i]]-f[j][l[j]];
          ll c=f[j][r[j]]-f[j][l[i]];
          ll d=f[i][r[j]]-f[i][l[i]];
            if(a>=b&&(b+c-d)>=a){
              ans++;
            }
          }
        }
      }
    }
  }
  cout<<ans<<endl;
}
0