Submission #501026

# Submission time Handle Problem Language Result Execution time Memory
501026 2022-01-02T08:22:11 Z dostigator Gift (IZhO18_nicegift) C++17
30 / 100
270 ms 66712 KB
// author lox:(
#pragma GCC optimize("O3")
#pragma GCC target("popcnt")
#include <bits/stdc++.h>
using namespace std;
#define popcnt __builtin_popcount
#define all(a) a.begin(),a.end()
#define low_b lower_bound
#define up_b upper_bound
#define vii vector<pair<ll,ll>>
#define vll vector<pair<ll,ll>>
#define pii pair<ll,ll>
#define mii map<ll,ll>
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vi vector<ll>
#define vl vector<ll>
#define pb push_back
#define endl '\n'
#define Y second
#define X first
typedef long double ld;
typedef long long ll;
const ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1},col=107,N=3e6+777;
const ll mod=1e9+7,inf=1e18;
void fre_open(){freopen("file.in","r",stdin);freopen("file.out","w",stdout);}
ll binpow(ll n,ll k){if(k<0)return 0ll;if(k==0)return 1ll;if(k%2)return (binpow(n,k-1)*n)%mod;ll kk=binpow(n,k/2)%mod;return (kk*kk)%mod;}
void solve(){
	int n,k,sum=0;
	cin>>n>>k;
	int a[n+1];
	set<pii>s;
	for(int i=1; i<=n; ++i){
        cin>>a[i];
		s.insert({a[i],i});
        sum+=a[i];
	}
	if(sum%k) {cout<<"-1\n";return;}
	if(sum<(*s.rbegin()).X*k) {cout<<"-1\n";return;}
	cout<<sum/k<<endl;
	for(int i=1; i<=sum/k; ++i){
        cout<<1<<' ';
        vector<pii> gg;
        if(s.size()<k){
            cout<<"-1\n";
            return;
        }
		for(int j=1; j<=k; ++j){
            pii v=*s.rbegin();
            s.erase(v);
            gg.pb(v);
            cout<<v.Y<<' ';
		}
		for(int j=0; j<=k; ++j){
            pii v=gg[j];
            v.X--;
            s.insert(v);
		}
	}
}
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //fre_open
    ll tt=1;
    //cin>>tt;
    while(tt--) solve();
}

Compilation message

nicegift.cpp: In function 'void solve()':
nicegift.cpp:44:20: warning: comparison of integer expressions of different signedness: 'std::set<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |         if(s.size()<k){
      |            ~~~~~~~~^~
nicegift.cpp: In function 'void fre_open()':
nicegift.cpp:26:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 | void fre_open(){freopen("file.in","r",stdin);freopen("file.out","w",stdout);}
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
nicegift.cpp:26:53: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 | void fre_open(){freopen("file.in","r",stdin);freopen("file.out","w",stdout);}
      |                                              ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB n=4
2 Correct 0 ms 204 KB n=3
3 Correct 0 ms 204 KB n=3
4 Correct 1 ms 204 KB n=4
5 Correct 0 ms 204 KB n=4
6 Correct 0 ms 204 KB n=2
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB n=4
2 Correct 0 ms 204 KB n=3
3 Correct 0 ms 204 KB n=3
4 Correct 1 ms 204 KB n=4
5 Correct 0 ms 204 KB n=4
6 Correct 0 ms 204 KB n=2
7 Correct 0 ms 204 KB n=5
8 Correct 0 ms 204 KB n=8
9 Correct 7 ms 332 KB n=14
10 Correct 5 ms 332 KB n=11
11 Correct 54 ms 4292 KB n=50000
12 Correct 57 ms 4336 KB n=50000
13 Correct 22 ms 592 KB n=10
14 Correct 26 ms 732 KB n=685
15 Correct 28 ms 720 KB n=623
16 Correct 15 ms 612 KB n=973
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB n=4
2 Correct 0 ms 204 KB n=3
3 Correct 0 ms 204 KB n=3
4 Correct 1 ms 204 KB n=4
5 Correct 0 ms 204 KB n=4
6 Correct 0 ms 204 KB n=2
7 Correct 0 ms 204 KB n=5
8 Correct 0 ms 204 KB n=8
9 Correct 7 ms 332 KB n=14
10 Correct 5 ms 332 KB n=11
11 Correct 54 ms 4292 KB n=50000
12 Correct 57 ms 4336 KB n=50000
13 Correct 22 ms 592 KB n=10
14 Correct 26 ms 732 KB n=685
15 Correct 28 ms 720 KB n=623
16 Correct 15 ms 612 KB n=973
17 Correct 28 ms 708 KB n=989
18 Correct 14 ms 464 KB n=563
19 Correct 28 ms 656 KB n=592
20 Correct 26 ms 732 KB n=938
21 Correct 19 ms 572 KB n=747
22 Correct 20 ms 568 KB n=991
# Verdict Execution time Memory Grader output
1 Incorrect 270 ms 66712 KB Jury has the answer but participant has not
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB n=4
2 Correct 0 ms 204 KB n=3
3 Correct 0 ms 204 KB n=3
4 Correct 1 ms 204 KB n=4
5 Correct 0 ms 204 KB n=4
6 Correct 0 ms 204 KB n=2
7 Correct 0 ms 204 KB n=5
8 Correct 0 ms 204 KB n=8
9 Correct 7 ms 332 KB n=14
10 Correct 5 ms 332 KB n=11
11 Correct 54 ms 4292 KB n=50000
12 Correct 57 ms 4336 KB n=50000
13 Correct 22 ms 592 KB n=10
14 Correct 26 ms 732 KB n=685
15 Correct 28 ms 720 KB n=623
16 Correct 15 ms 612 KB n=973
17 Correct 28 ms 708 KB n=989
18 Correct 14 ms 464 KB n=563
19 Correct 28 ms 656 KB n=592
20 Correct 26 ms 732 KB n=938
21 Correct 19 ms 572 KB n=747
22 Correct 20 ms 568 KB n=991
23 Incorrect 270 ms 66712 KB Jury has the answer but participant has not
24 Halted 0 ms 0 KB -