Submission #482360

# Submission time Handle Problem Language Result Execution time Memory
482360 2021-10-24T06:42:36 Z lollipop Gift (IZhO18_nicegift) C++17
0 / 100
627 ms 77260 KB
#include<bits/stdc++.h>
#define int long long 
#define pb push_back
#define s second
#define f first
using namespace std ;
const int mod =  1000000007 ;
map < int , int > ma ; 
signed main(){
	ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
    int n , k ; 
    cin >> n >> k ; 
    vector < vector < int > > v ; 
    multiset < pair < int , int > > se ; 
    for( int j = 1 ; j <= n ; j ++ ){
    	int x ; cin >> x ; 
    	se.insert( { x , j } ) ; 
	}
    while( se.size() > 0 ){
    	  vector < int > ve ; 
    	  if( se.size() < k ){
    	  	  cout << -1 ; 
    	  	  return 0 ; 
		  }
    	  int k1 = k - 1 ;
		  pair < int , int > p ; 
		  p = *se.begin() ;
		  int mn = p.f ; 
		  ve.pb( p.s ) ; 
		  se.erase( se.begin() ) ;   
		  vector < pair < int , int > > z ; 
    	  while( k1 -- ){
    	  	   pair < int , int > pa ; 
    	  	   pa = *se.begin() ; 
    	  	   ve.pb( pa.s ) ; 
    	  	   se.erase( se.begin() ) ; 
    	  	   pa.f -= mn ; 
    	  	   if( pa.f != 0 ) z.pb( pa ) ; 
		  }
		  for( int j = 0 ; j < z.size() ; j ++ ) se.insert( z[ j ] ) ; 
		  ve.pb( p.f ) ;
		  v.pb( ve ) ;  
	}
	cout << v.size() << "\n"; 
     for( int j = 0 ; j < v.size() ; j ++ ){
     	for( int i = 0; i < v[ j ].size() ; i ++ ) cout << v[ j ][ i ] << " " ; cout << '\n' ; }
	 
}

Compilation message

nicegift.cpp: In function 'int main()':
nicegift.cpp:21:22: warning: comparison of integer expressions of different signedness: 'std::multiset<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'long long int' [-Wsign-compare]
   21 |        if( se.size() < k ){
      |            ~~~~~~~~~~^~~
nicegift.cpp:40:24: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     for( int j = 0 ; j < z.size() ; j ++ ) se.insert( z[ j ] ) ;
      |                      ~~^~~~~~~~~~
nicegift.cpp:45:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |      for( int j = 0 ; j < v.size() ; j ++ ){
      |                       ~~^~~~~~~~~~
nicegift.cpp:46:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |       for( int i = 0; i < v[ j ].size() ; i ++ ) cout << v[ j ][ i ] << " " ; cout << '\n' ; }
      |                       ~~^~~~~~~~~~~~~~~
nicegift.cpp:46:7: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   46 |       for( int i = 0; i < v[ j ].size() ; i ++ ) cout << v[ j ][ i ] << " " ; cout << '\n' ; }
      |       ^~~
nicegift.cpp:46:79: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   46 |       for( int i = 0; i < v[ j ].size() ; i ++ ) cout << v[ j ][ i ] << " " ; cout << '\n' ; }
      |                                                                               ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Same heap occurs twice
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Same heap occurs twice
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Same heap occurs twice
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 627 ms 77260 KB Expected int32, but "1000000000000" found
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Same heap occurs twice
2 Halted 0 ms 0 KB -