답안 #493805

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
493805 2021-12-13T03:06:09 Z khangal Gift (IZhO18_nicegift) C++14
30 / 100
2000 ms 175776 KB
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef double db;
typedef vector<long long> vl;
typedef pair<long long, long long > pl;
const int N = 1e6 + 1;
#define po pop_back
#define pb push_back
#define mk make_pair
#define lw lower_bound
#define up upper_bound
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(); cin.tie(0); cout.tie(0);
#define MOD 1000000007
#define MAX 1e18 
#define MIN -1e18
#define per(i,a,b) for(ll i=b;i>=a;i--)
#define con continue
#define freopen freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define PI 3.14159265358979323846264338327950288419716939937510582097494459230781640628
// typedef tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// template< typename T>
// using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll n, m, ans, mid, mn, mx, cnt, sum, h1, h2, arr[3234567],arr1[1234567], sz, k, i, j, h, a, w, x, y, z,par[1234567];
bool used[1234567];
//ll dx[4]={-1,1,0,0},dy[4]={0,0,-1,1},c1[123][123];
//vector<ll> edge[1234567];
//ll jump[22][223456];
//ll lvl[1234567];
//ll bit[1234567];
//ll timer;
//ll st[1234567],endd[1234567];
//ll dp[5005][5005];
ll power(ll base, ll val, ll mod) {
    ll res = 1;
    while (val) {
        if (val % 2 == 1) {
            res = res * base;
        }
        base = base * base;
        base %= mod;
        res %= mod;
        val /= 2;
    }
    return res;
}
bool comp(pl x,pl y){
    if(x.ff>y.ff)return true;
    return false;
}
ll find(ll x){
    if(x==par[x])return x;
    else return par[x]=find(par[x]);
}
pl findnum(ll x){
    ll res = x*x;
    ll l = n/x;
    l*=l;
    if(l%2==1){
        return {res*(l/2+1) , res*((l/2))};
    }
    else{
        return {res*(l/2) , res*((l/2))};        
    }
}
bool check(ll x,ll y,ll k){
    ll res = (x+k-1)/k + (y-1+k)/k;
    if(res%2==1)return false;
    else return true;
}
ll find(ll x, ll d){
    return x / (2 * d) * d + min(x % (2 * d), d);
}
class A {
public:
    static void funcA() {
        ll n, k;
        cin>>n>>k; 
        set<pl> st;
        for(int i = 1; i <= n; i++){
            cin>>x;
            st.insert({-x, i}); 
        }
        vector<vector<pl>> answer;
        while(st.begin()->ff < 0) {
            vector<pl> v; 
            for(pl p : st) {
                v.pb(p);
                if(v.size() == k) break;
            }
            for(pl p : v) {
                st.erase(p);
                p.ff++;
                if(p.first > 0) {
                    cout<<"-1\n";
                    return ;
                }
                st.insert(p);
            }
            answer.pb(v);
        }
        cout<<answer.size()<<'\n';
        for(auto v : answer) {
            cout<<1<<' ';
            for(pl p : v) { 
                cout<<p.ss<<' ';
            }
            cout<<'\n';
        }
    }
}lol;
void solve() {
    A::funcA();
}
int main() {
    ll T = 1;
    //cin>>T;
    boost;
    while (T--) {
        solve();
    }
}

Compilation message

nicegift.cpp: In static member function 'static void A::funcA()':
nicegift.cpp:94:29: warning: comparison of integer expressions of different signedness: 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} and 'll' {aka 'long long int'} [-Wsign-compare]
   94 |                 if(v.size() == k) break;
      |                    ~~~~~~~~~^~~~
# 결과 실행 시간 메모리 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 1 ms 204 KB n=2
# 결과 실행 시간 메모리 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 1 ms 204 KB n=2
7 Correct 1 ms 204 KB n=5
8 Correct 3 ms 972 KB n=8
9 Correct 9 ms 1420 KB n=14
10 Correct 5 ms 1104 KB n=11
11 Correct 58 ms 7780 KB n=50000
12 Correct 57 ms 7660 KB n=50000
13 Correct 31 ms 4208 KB n=10
14 Correct 30 ms 3772 KB n=685
15 Correct 33 ms 4000 KB n=623
16 Correct 18 ms 2440 KB n=973
# 결과 실행 시간 메모리 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 1 ms 204 KB n=2
7 Correct 1 ms 204 KB n=5
8 Correct 3 ms 972 KB n=8
9 Correct 9 ms 1420 KB n=14
10 Correct 5 ms 1104 KB n=11
11 Correct 58 ms 7780 KB n=50000
12 Correct 57 ms 7660 KB n=50000
13 Correct 31 ms 4208 KB n=10
14 Correct 30 ms 3772 KB n=685
15 Correct 33 ms 4000 KB n=623
16 Correct 18 ms 2440 KB n=973
17 Correct 30 ms 3516 KB n=989
18 Correct 15 ms 1616 KB n=563
19 Correct 23 ms 2452 KB n=592
20 Correct 25 ms 2384 KB n=938
21 Correct 20 ms 1936 KB n=747
22 Correct 21 ms 2120 KB n=991
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2037 ms 175776 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 204 KB n=2
7 Correct 1 ms 204 KB n=5
8 Correct 3 ms 972 KB n=8
9 Correct 9 ms 1420 KB n=14
10 Correct 5 ms 1104 KB n=11
11 Correct 58 ms 7780 KB n=50000
12 Correct 57 ms 7660 KB n=50000
13 Correct 31 ms 4208 KB n=10
14 Correct 30 ms 3772 KB n=685
15 Correct 33 ms 4000 KB n=623
16 Correct 18 ms 2440 KB n=973
17 Correct 30 ms 3516 KB n=989
18 Correct 15 ms 1616 KB n=563
19 Correct 23 ms 2452 KB n=592
20 Correct 25 ms 2384 KB n=938
21 Correct 20 ms 1936 KB n=747
22 Correct 21 ms 2120 KB n=991
23 Execution timed out 2037 ms 175776 KB Time limit exceeded
24 Halted 0 ms 0 KB -