Submission #482361

#TimeUsernameProblemLanguageResultExecution timeMemory
482361lollipopGift (IZhO18_nicegift)C++17
0 / 100
630 ms77336 KiB
#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( mn ) ; 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 ] ) ; //sort( ve.begin() , ve.end() ) ; // 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 (stderr)

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:41: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]
   41 |     for( int j = 0 ; j < z.size() ; j ++ ) se.insert( z[ j ] ) ;
      |                      ~~^~~~~~~~~~
nicegift.cpp:47: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]
   47 |      for( int j = 0 ; j < v.size() ; j ++ ){
      |                       ~~^~~~~~~~~~
nicegift.cpp:48: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]
   48 |       for( int i = 0; i < v[ j ].size() ; i ++ ) cout << v[ j ][ i ] << " " ; cout << '\n' ; }
      |                       ~~^~~~~~~~~~~~~~~
nicegift.cpp:48:7: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   48 |       for( int i = 0; i < v[ j ].size() ; i ++ ) cout << v[ j ][ i ] << " " ; cout << '\n' ; }
      |       ^~~
nicegift.cpp:48:79: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   48 |       for( int i = 0; i < v[ j ].size() ; i ++ ) cout << v[ j ][ i ] << " " ; cout << '\n' ; }
      |                                                                               ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...