Submission #768062

# Submission time Handle Problem Language Result Execution time Memory
768062 2023-06-27T12:05:55 Z lollipop Intercastellar (JOI22_ho_t1) C++17
100 / 100
214 ms 7632 KB
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define int long long
#define pb push_back
#define s second
#define f first
#define pf push_front
#define inf 100000000000000000
#define bitebi __builtin_popcountll
#define FOR( i , n ) for( int i = 0 ; i < n ; i ++ )
#define YES cout <<"YES\n"
#define NO cout << "NO\n"
#define debug cout << "Here Fine" << endl ;
#define pr pair < int , int >
#define fbo find_by_order // returns iterator
#define ook order_of_key // returns strictly less numbers than key
using namespace std ;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const double Pi=acos(-1.0);
const double EPS=1E-8;
const int mod =  1000000007 ;
const int mod1 = 998244353 ;
const int N = 2e5 + 10 ;
mt19937 R(time(0));
map < int , int > ma , ma1 ;
int get( int num ){
	if( num % 2 == 1 ) return 1 ;
	int cur = get( num / 2 ) * 2 ; 
	return cur ; 
}
int gamot( int num , int nd ){
	if( num % 2 == 1 ) return num ;
	if( get( num / 2 ) >= nd ){
		return gamot( num / 2 , nd ) ; 
	}
	return gamot( num / 2 , nd - get( num / 2 ) ) ; 
}
void solve(){
     int n ; cin >> n ;
     int a[ n ] ; 
     FOR( i , n ) cin >> a[ i ] ;
     int q ; cin >> q ;
     int pos = 0 , j = 0 ; 
     while( q -- ){
     	int x ; cin >> x ;
	    int nd = x - pos ; 
        while( true ){
        	int cnt = get( a[ j ] ) ;
        	if( nd <= cnt ) break ;
			pos = pos + cnt ;  
        	nd = nd - cnt ; j ++ ;
		}  
		cout << gamot( a[ j ] , nd ) << "\n" ; 
	 }
     
}
signed main() {
   ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
   int t = 1 ;// cin >> t ;
   while( t -- ){
   	 solve() ;
   }

}




# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 16 ms 2504 KB Output is correct
4 Correct 23 ms 1868 KB Output is correct
5 Correct 41 ms 3928 KB Output is correct
6 Correct 31 ms 2748 KB Output is correct
7 Correct 39 ms 3968 KB Output is correct
8 Correct 40 ms 4044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 324 KB Output is correct
5 Correct 1 ms 324 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 324 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 324 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 340 KB Output is correct
12 Correct 2 ms 332 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 16 ms 2504 KB Output is correct
4 Correct 23 ms 1868 KB Output is correct
5 Correct 41 ms 3928 KB Output is correct
6 Correct 31 ms 2748 KB Output is correct
7 Correct 39 ms 3968 KB Output is correct
8 Correct 40 ms 4044 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 324 KB Output is correct
13 Correct 1 ms 324 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 324 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 340 KB Output is correct
20 Correct 2 ms 332 KB Output is correct
21 Correct 1 ms 212 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 21 ms 2724 KB Output is correct
24 Correct 27 ms 4040 KB Output is correct
25 Correct 54 ms 7244 KB Output is correct
26 Correct 76 ms 4568 KB Output is correct
27 Correct 56 ms 4384 KB Output is correct
28 Correct 118 ms 7632 KB Output is correct
29 Correct 214 ms 7044 KB Output is correct
30 Correct 102 ms 3512 KB Output is correct
31 Correct 154 ms 7500 KB Output is correct