Submission #55069961


Source Code Expand

Copy
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pii> vii;
#define INF 10000000000000000
#define inf 1000000000
// #define MOD 1000000007
// #define MOD 672804213107214
// #define MOD 998244353
#define PI 3.1415926535897932385
#define pb push_back
#define bitc __builtin_popcountll
#define mp make_pair
#define all(ar) ar.begin(), ar.end()
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> piii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<pii> vii;
 #define INF 10000000000000000
#define inf 1000000000
// #define MOD  1000000007
// #define MOD 672804213107214
// #define MOD 998244353
#define PI 3.1415926535897932385
 #define pb push_back
#define bitc __builtin_popcountll
#define mp make_pair
#define all(ar) ar.begin(), ar.end()
#define fr(i, a, b) for (int i = (a), _b = (b); i <= _b; i++)
#define rep(i, n) for (int i = 0, _n = (n); i < _n; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define frr(i, a, b) for (int i = (a), _b = (b); i >= _b; i--)
#define foreach(it, ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fil(ar, val) memset(ar, val, sizeof(ar))  // 0x3f for inf, 0x80 for -INF can also use with pairs
#define print(a) for(auto x : a) cout << x << " "; cout << endl
#define print1(a) for(auto x : a) cout << x.first << " " << x.second << endl
#define print2(a,x,y)  for(int i = x; i < y; i++) cout<< a[i]<< " "; cout << endl
#define bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)
 template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
   const char* comma = strchr (names + 1, ',');
   cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}
void solve()
{
  //vector<int> sieve(N+1,0); //fill constructor
    //primeSieve(sieve);
    vector<ll>vec1,vec2;
    ll n,t;
    cin>>n>>t;
    t*=10;
    t++;
    string str;
    cin>>str;
    for(int i=1;i<=n;i++)
    {
        ll x;
        cin>>x;
        if(str[i-1]=='0')
        {
            vec1.pb(x*10);
        }
        else
        {
            vec2.pb(x*10);
        }
    }
    sort(vec1.begin(),vec1.end());
    sort(vec2.begin(),vec2.end());
    ll l1=0,l2=0;
    vector<ll>vec3;
    ll sum=0;
    while(l1<vec1.size()&&l2<vec2.size())
    {
        if((vec2[l2]<vec1[l1]))
        {
            vec3.pb(vec2[l2]+(t));
            l2++;
        }
        else
        {
            auto it=upper_bound(vec3.begin(),vec3.end(),vec1[l1]-t);
            sum+=vec3.size()-(int)(it-vec3.begin());
            l1++;
        }
        // cout<<sum<<" "<<l1<<" "<<l2<<"\n";

    }
    while(l1<vec1.size())
    {
           auto it=upper_bound(vec3.begin(),vec3.end(),vec1[l1]-t);
            sum+=vec3.size()-(int)(it-vec3.begin());
            l1++;
    }
    cout<<sum;
}
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0), cout.precision(15);   cout<<fixed;
int t=1;
// cin>>t;
while(t--)
{
   solve();
}
}

Submission Info

Submission Time
Task D - Ghost Ants
User SanathSalampuria
Language C++ 20 (gcc 12.2)
Score 350
Code Size 2961 Byte
Status AC
Exec Time 31 ms
Memory 6568 KB

Compile Error

Main.cpp: In function ‘void solve()’:
Main.cpp:69:13: warning: comparison of integer expressions of different signedness: ‘ll’ {aka ‘long long int’} and ‘std::vector<long long int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   69 |     while(l1<vec1.size()&&l2<vec2.size())
      |           ~~^~~~~~~~~~~~
Main.cpp:69:29: warning: comparison of integer expressions of different signedness: ‘ll’ {aka ‘long long int’} and ‘std::vector<long long int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   69 |     while(l1<vec1.size()&&l2<vec2.size())
      |                           ~~^~~~~~~~~~~~
Main.cpp:85:13: warning: comparison of integer expressions of different signedness: ‘ll’ {aka ‘long long int’} and ‘std::vector<long long int>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   85 |     while(l1<vec1.size())
      |           ~~^~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 350 / 350
Status
AC × 2
AC × 28
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt
All 00_sample_00.txt, 00_sample_01.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3480 KB
00_sample_01.txt AC 1 ms 3472 KB
01_random_00.txt AC 30 ms 6332 KB
01_random_01.txt AC 18 ms 4876 KB
01_random_02.txt AC 30 ms 6436 KB
01_random_03.txt AC 24 ms 6112 KB
01_random_04.txt AC 30 ms 6512 KB
01_random_05.txt AC 15 ms 4900 KB
01_random_06.txt AC 30 ms 6496 KB
01_random_07.txt AC 24 ms 6116 KB
01_random_08.txt AC 29 ms 6288 KB
01_random_09.txt AC 28 ms 6120 KB
01_random_10.txt AC 31 ms 6408 KB
01_random_11.txt AC 27 ms 6244 KB
01_random_12.txt AC 30 ms 6232 KB
01_random_13.txt AC 23 ms 5912 KB
01_random_14.txt AC 29 ms 6512 KB
01_random_15.txt AC 16 ms 4920 KB
01_random_16.txt AC 30 ms 6480 KB
01_random_17.txt AC 23 ms 6016 KB
01_random_18.txt AC 30 ms 6484 KB
01_random_19.txt AC 25 ms 6068 KB
01_random_20.txt AC 16 ms 6488 KB
01_random_21.txt AC 16 ms 6436 KB
01_random_22.txt AC 18 ms 6344 KB
01_random_23.txt AC 18 ms 6440 KB
01_random_24.txt AC 17 ms 6568 KB
01_random_25.txt AC 17 ms 6524 KB


2025-03-29 (Sat)
09:38:06 +00:00