답안 #334383

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
334383 2020-12-09T05:41:56 Z beksultan04 Gift (IZhO18_nicegift) C++14
0 / 100
34 ms 1900 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define OK puts("OK");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%lld",&a);
#define scan2(a,b) scanf("%lld %lld",&a, &b);
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define pb push_back
#define endi puts("");
const int N = 1e5+12,INF=1e9+7;
int resh[N],q[N],n;
multiset<int> s;
main(){

    int n,m,i,j,sum=0,ans=1;
    scan2(n,m)
    for (i=0;i<n;++i){
        scan1(q[i])
        sum+=q[i];
    }
    sort(q,q+n);
    if (sum%m == 0){
        cout <<sum/m<<"\n";
        while (sum > 0){
            sum -= q[0]*m;
            int c=0;
            cout <<q[0]<<" ";
            while (c < m){
                c++;
                cout <<ans++<<" ";
            }
            cout <<endl;
        }
    }
    else {
        cout <<-1;
    }

}


















Compilation message

nicegift.cpp:18:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   18 | main(){
      |      ^
nicegift.cpp: In function 'int main()':
nicegift.cpp:20:15: warning: unused variable 'j' [-Wunused-variable]
   20 |     int n,m,i,j,sum=0,ans=1;
      |               ^
nicegift.cpp:10:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~
nicegift.cpp:21:5: note: in expansion of macro 'scan2'
   21 |     scan2(n,m)
      |     ^~~~~
nicegift.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 | #define scan1(a) scanf("%lld",&a);
      |                  ~~~~~^~~~~~~~~~~
nicegift.cpp:23:9: note: in expansion of macro 'scan1'
   23 |         scan1(q[i])
      |         ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Integer 5 violates the range [1, 4]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Integer 5 violates the range [1, 4]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Integer 5 violates the range [1, 4]
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 34 ms 1900 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Integer 5 violates the range [1, 4]
2 Halted 0 ms 0 KB -