# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
334465 | 2020-12-09T07:41:36 Z | beksultan04 | Gift (IZhO18_nicegift) | C++14 | 2000 ms | 115156 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 dist[N],n; vector <pii> g[N]; void fun(int v){ int i,j,k; set <pii> s; s.insert({0,v}); dist[v] = 0; while (!s.empty()){ pii x = *s.begin(); s.erase(s.begin()); for (i=0;i<g[x.sc].size();++i){ if (dist[g[x.sc][i].fr] > dist[x.sc]+g[x.sc][i].sc){ s.erase({dist[g[x.sc][i].fr],g[x.sc][i].fr}); dist[g[x.sc][i].fr] = dist[x.sc]+g[x.sc][i].sc; s.insert({dist[g[x.sc][i].fr],g[x.sc][i].fr}); } } } } main(){ int n,k,i,j; multiset<pii> s; vector <pair<pii,int> > v; scan2(n,k) for (i=0;i<n;++i){ int x; scan1(x) s.insert({x,i+1}); } while (s.size()>2){ pii x = *s.rbegin(); s.erase(x); pii y = *s.rbegin(); s.erase(y); pii z = *s.rbegin(); int a = y.fr-z.fr+1; v.pb({{a,x.sc},y.sc}); x.fr -= a; y.fr -= a; if (x.fr > 0)s.insert(x); if (y.fr > 0)s.insert(y); } if (s.size() == 2){ pii x = *s.rbegin(); s.erase(x); pii y = *s.rbegin(); s.erase(y); if (x.fr == y.fr){ v.pb({{x.fr,x.sc},y.sc}); cout <<v.size()<<"\n"; for (i=0;i<v.size();++i){ cout <<v[i].fr.fr<<" "<<v[i].fr.sc<<" "<<v[i].sc<<"\n"; } } else { cout <<-1; } } else if (v.empty() || s.size() == 1)cout <<-1; else{ cout <<v.size()<<"\n"; for (i=0;i<v.size();++i){ cout <<v[i].fr.fr<<" "<<v[i].fr.sc<<" "<<v[i].sc<<"\n"; } } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2668 KB | n=4 |
2 | Correct | 2 ms | 2668 KB | n=3 |
3 | Correct | 2 ms | 2668 KB | n=3 |
4 | Correct | 2 ms | 2668 KB | n=4 |
5 | Correct | 2 ms | 2668 KB | n=4 |
6 | Correct | 3 ms | 2668 KB | n=2 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2668 KB | n=4 |
2 | Correct | 2 ms | 2668 KB | n=3 |
3 | Correct | 2 ms | 2668 KB | n=3 |
4 | Correct | 2 ms | 2668 KB | n=4 |
5 | Correct | 2 ms | 2668 KB | n=4 |
6 | Correct | 3 ms | 2668 KB | n=2 |
7 | Correct | 2 ms | 2668 KB | n=5 |
8 | Correct | 3 ms | 2668 KB | n=8 |
9 | Correct | 7 ms | 3248 KB | n=14 |
10 | Correct | 4 ms | 2992 KB | n=11 |
11 | Correct | 36 ms | 7148 KB | n=50000 |
12 | Correct | 51 ms | 7652 KB | n=50000 |
13 | Correct | 19 ms | 3564 KB | n=10 |
14 | Correct | 31 ms | 4324 KB | n=685 |
15 | Correct | 33 ms | 4324 KB | n=623 |
16 | Correct | 20 ms | 3692 KB | n=973 |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2668 KB | n=4 |
2 | Correct | 2 ms | 2668 KB | n=3 |
3 | Correct | 2 ms | 2668 KB | n=3 |
4 | Correct | 2 ms | 2668 KB | n=4 |
5 | Correct | 2 ms | 2668 KB | n=4 |
6 | Correct | 3 ms | 2668 KB | n=2 |
7 | Correct | 2 ms | 2668 KB | n=5 |
8 | Correct | 3 ms | 2668 KB | n=8 |
9 | Correct | 7 ms | 3248 KB | n=14 |
10 | Correct | 4 ms | 2992 KB | n=11 |
11 | Correct | 36 ms | 7148 KB | n=50000 |
12 | Correct | 51 ms | 7652 KB | n=50000 |
13 | Correct | 19 ms | 3564 KB | n=10 |
14 | Correct | 31 ms | 4324 KB | n=685 |
15 | Correct | 33 ms | 4324 KB | n=623 |
16 | Correct | 20 ms | 3692 KB | n=973 |
17 | Incorrect | 36 ms | 4456 KB | Taken too much stones from the heap |
18 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 2090 ms | 115156 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 2668 KB | n=4 |
2 | Correct | 2 ms | 2668 KB | n=3 |
3 | Correct | 2 ms | 2668 KB | n=3 |
4 | Correct | 2 ms | 2668 KB | n=4 |
5 | Correct | 2 ms | 2668 KB | n=4 |
6 | Correct | 3 ms | 2668 KB | n=2 |
7 | Correct | 2 ms | 2668 KB | n=5 |
8 | Correct | 3 ms | 2668 KB | n=8 |
9 | Correct | 7 ms | 3248 KB | n=14 |
10 | Correct | 4 ms | 2992 KB | n=11 |
11 | Correct | 36 ms | 7148 KB | n=50000 |
12 | Correct | 51 ms | 7652 KB | n=50000 |
13 | Correct | 19 ms | 3564 KB | n=10 |
14 | Correct | 31 ms | 4324 KB | n=685 |
15 | Correct | 33 ms | 4324 KB | n=623 |
16 | Correct | 20 ms | 3692 KB | n=973 |
17 | Incorrect | 36 ms | 4456 KB | Taken too much stones from the heap |
18 | Halted | 0 ms | 0 KB | - |