답안 #171137

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
171137 2019-12-27T13:35:41 Z juggernaut Gift (IZhO18_nicegift) C++14
18 / 100
2000 ms 147744 KB
//Just try and the idea will come!
#include<bits/stdc++.h>
#define int long long int
using namespace std;
priority_queue<pair<int,int>>q;
int n,k,i,x;
pair<int,int>a,b;
vector<pair<int,int>>ans;
main(){
    scanf("%lld%lld",&n,&k);
    for(i=0;i<n;i++){
        scanf("%lld",&x);
        q.push({x,i+1});
    }
    while(!q.empty()){
        if(q.size()==1){
            puts("-1");
            return 0;
        }
        a=q.top();
        q.pop();
        b=q.top();
        q.pop();
        ans.push_back({b.second,a.second});
        if(a.first!=1)q.push({a.first-1,a.second});
        if(b.first!=1)q.push({b.first-1,b.second});
    }
    printf("%lld\n",(int)ans.size());
    for(auto res:ans)printf("1 %lld %lld\n",res.first,res.second);
}

Compilation message

nicegift.cpp:9:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
nicegift.cpp: In function 'int main()':
nicegift.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld",&n,&k);
     ~~~~~^~~~~~~~~~~~~~~~~~
nicegift.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&x);
         ~~~~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n=4
2 Correct 2 ms 256 KB n=3
3 Correct 2 ms 256 KB n=3
4 Correct 2 ms 256 KB n=4
5 Correct 2 ms 376 KB n=4
6 Correct 2 ms 376 KB n=2
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n=4
2 Correct 2 ms 256 KB n=3
3 Correct 2 ms 256 KB n=3
4 Correct 2 ms 256 KB n=4
5 Correct 2 ms 376 KB n=4
6 Correct 2 ms 376 KB n=2
7 Correct 2 ms 376 KB n=5
8 Correct 4 ms 760 KB n=8
9 Correct 6 ms 764 KB n=14
10 Correct 3 ms 760 KB n=11
11 Correct 33 ms 2836 KB n=50000
12 Correct 30 ms 2796 KB n=50000
13 Correct 15 ms 1644 KB n=10
14 Correct 17 ms 1520 KB n=685
15 Correct 19 ms 1640 KB n=623
16 Correct 11 ms 1136 KB n=973
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n=4
2 Correct 2 ms 256 KB n=3
3 Correct 2 ms 256 KB n=3
4 Correct 2 ms 256 KB n=4
5 Correct 2 ms 376 KB n=4
6 Correct 2 ms 376 KB n=2
7 Correct 2 ms 376 KB n=5
8 Correct 4 ms 760 KB n=8
9 Correct 6 ms 764 KB n=14
10 Correct 3 ms 760 KB n=11
11 Correct 33 ms 2836 KB n=50000
12 Correct 30 ms 2796 KB n=50000
13 Correct 15 ms 1644 KB n=10
14 Correct 17 ms 1520 KB n=685
15 Correct 19 ms 1640 KB n=623
16 Correct 11 ms 1136 KB n=973
17 Incorrect 21 ms 1644 KB Taken too much stones from the heap
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2072 ms 147744 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB n=4
2 Correct 2 ms 256 KB n=3
3 Correct 2 ms 256 KB n=3
4 Correct 2 ms 256 KB n=4
5 Correct 2 ms 376 KB n=4
6 Correct 2 ms 376 KB n=2
7 Correct 2 ms 376 KB n=5
8 Correct 4 ms 760 KB n=8
9 Correct 6 ms 764 KB n=14
10 Correct 3 ms 760 KB n=11
11 Correct 33 ms 2836 KB n=50000
12 Correct 30 ms 2796 KB n=50000
13 Correct 15 ms 1644 KB n=10
14 Correct 17 ms 1520 KB n=685
15 Correct 19 ms 1640 KB n=623
16 Correct 11 ms 1136 KB n=973
17 Incorrect 21 ms 1644 KB Taken too much stones from the heap
18 Halted 0 ms 0 KB -