Submission #37151194


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

#define ll                      long long
#define sz(x)                   (int)((x).size())
#define all(a)                  a.begin(), a.end()


template <typename T, typename U>static inline void amin(T &x, U y){if (y < x) x = y;}
template <typename T, typename U>static inline void amax(T &x, U y){if (x < y)x = y;}
ll cdiv(ll a, ll b) { return a / b + ((a ^ b) > 0 && a % b); }
ll fdiv(ll a, ll b) { return a / b - ((a ^ b) < 0 && a % b); }


ll gcd(ll a, ll b)
{if (b == 0)
           return (a);
    else
         return (gcd(b, a % b));
}

 
//#define runSieve 
vector<bool> prime(10000005, true); 
void sieve(ll n = 10000002){
prime[1] = false;
for (ll p = 2; p * p <= n; p++)
     {if (prime[p] == true)
             for (ll i = p * p; i <= n; i += p) 
                    prime[i] = false; 
      }
}
 
//******************************************************************************************************************

void fn()
{
  ll n,t;
  cin>>n>>t;
  vector<ll>v(n);

  for(auto &x:v)cin>>x;

    vector<ll>pre(n,0);
  pre[0]=v[0];
  for(int j=1;j<n;j++)
    pre[j]=pre[j-1]+v[j];
   ll sum=pre[n-1];
   ll r=t%sum;
   if(n==1){
    cout<<"1 ";
    cout<<r<<'\n';
    return ;
   }
   if(r==0){
    cout<<"1 0\n";
    return;
   }
   // cout<<r<<'\n';
   auto itr=upper_bound(all(pre),r)-pre.begin();
   // itr--;
   cout<<itr+1<<' ';
   if(itr==0){
    cout<<r;
   }else {
    cout<<r-pre[itr-1];
   }
}

int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);


   ll TESTS = 1;
   //cin >> TESTS;
   for(int t=1;t<=TESTS;t++){
   //cout<<"Case #"<<t<<": ";
     fn();
   }
   return 0;    
}

Submission Info

Submission Time
Task C - Circular Playlist
User good4nothing
Language C++ (GCC 9.2.1)
Score 300
Code Size 1752 Byte
Status AC
Exec Time 20 ms
Memory 5968 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 27
Set Name Test Cases
Sample 00_example_00.txt, 00_example_01.txt, 00_example_02.txt
All 00_example_00.txt, 00_example_01.txt, 00_example_02.txt, 01_max_00.txt, 01_max_01.txt, 02_min_00.txt, 02_min_01.txt, 03_small_00.txt, 03_small_01.txt, 03_small_02.txt, 03_small_03.txt, 03_small_04.txt, 03_small_05.txt, 03_small_06.txt, 03_small_07.txt, 03_small_08.txt, 03_small_09.txt, 04_random_00.txt, 04_random_01.txt, 04_random_02.txt, 04_random_03.txt, 04_random_04.txt, 04_random_05.txt, 04_random_06.txt, 04_random_07.txt, 04_random_08.txt, 04_random_09.txt
Case Name Status Exec Time Memory
00_example_00.txt AC 8 ms 4220 KiB
00_example_01.txt AC 3 ms 4316 KiB
00_example_02.txt AC 3 ms 4240 KiB
01_max_00.txt AC 20 ms 5964 KiB
01_max_01.txt AC 12 ms 5968 KiB
02_min_00.txt AC 4 ms 4164 KiB
02_min_01.txt AC 5 ms 4216 KiB
03_small_00.txt AC 10 ms 5128 KiB
03_small_01.txt AC 7 ms 4784 KiB
03_small_02.txt AC 7 ms 4868 KiB
03_small_03.txt AC 10 ms 5212 KiB
03_small_04.txt AC 4 ms 4236 KiB
03_small_05.txt AC 3 ms 4312 KiB
03_small_06.txt AC 13 ms 5920 KiB
03_small_07.txt AC 12 ms 5132 KiB
03_small_08.txt AC 12 ms 5488 KiB
03_small_09.txt AC 9 ms 5204 KiB
04_random_00.txt AC 10 ms 4964 KiB
04_random_01.txt AC 15 ms 5728 KiB
04_random_02.txt AC 14 ms 5436 KiB
04_random_03.txt AC 15 ms 5492 KiB
04_random_04.txt AC 10 ms 4864 KiB
04_random_05.txt AC 12 ms 4940 KiB
04_random_06.txt AC 8 ms 4832 KiB
04_random_07.txt AC 10 ms 4912 KiB
04_random_08.txt AC 16 ms 5732 KiB
04_random_09.txt AC 15 ms 5404 KiB