답안 #482359

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
482359 2021-10-24T06:38:45 Z lollipop Gift (IZhO18_nicegift) C++17
0 / 100
651 ms 91112 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() ) ;   
    	  while( k1 -- ){
    	  	   pair < int , int > pa ; 
    	  	   pa = *se.begin() ; 
    	  	   ve.pb( pa.s ) ; 
    	  	   se.erase( se.begin() ) ; 
    	  	   pa.f -= mn ; 
    	  	   if( pa.f != 0 ) se.insert( pa ) ; 
		  }
		  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:43: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]
   43 |      for( int j = 0 ; j < v.size() ; j ++ ){
      |                       ~~^~~~~~~~~~
nicegift.cpp:44: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]
   44 |       for( int i = 0; i < v[ j ].size() ; i ++ ) cout << v[ j ][ i ] << " " ; cout << '\n' ; }
      |                       ~~^~~~~~~~~~~~~~~
nicegift.cpp:44:7: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   44 |       for( int i = 0; i < v[ j ].size() ; i ++ ) cout << v[ j ][ i ] << " " ; cout << '\n' ; }
      |       ^~~
nicegift.cpp:44:79: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   44 |       for( int i = 0; i < v[ j ].size() ; i ++ ) cout << v[ j ][ i ] << " " ; cout << '\n' ; }
      |                                                                               ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Same heap occurs twice
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Same heap occurs twice
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Same heap occurs twice
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 651 ms 91112 KB Expected int32, but "1000000000000" found
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Same heap occurs twice
2 Halted 0 ms 0 KB -