| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 634016 | drkarlicio2107 | Gift (IZhO18_nicegift) | C++14 | 924 ms | 198384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
vector < pair <long long int, pair<long long int, long long int> > > s;
set <long long int> m;
long long int a [1000010];
vector <long long int> ans [3000010];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
long long int n, k; cin >> n >> k; long long int gr=0; long long int sum=0;
for (int i=0; i<n; i++){
long long int x; cin >> x; a[i]=x; sum+=a[i];
}
for (int i=0; i<n; i++){
long long int x=a[i];
s.push_back ({(gr)%(sum/k), {i, 0}}); gr+=x;
//cout << gr << endl;
if (gr%(sum/k)==0) s.push_back ({sum/k, {i, 1}});
else s.push_back ({(gr)%(sum/k), {i, 1}});
if ((gr-x)%(sum/k)>gr%(sum/k) && gr%(sum/k)!=0){
s.push_back ({0, {i, 0}});
s.push_back ({sum/k, {i, 1}});
}
}
if (gr%k!=0){
cout << -1; return 0;
}
long long int ind=0;
for (int i=0; i<n; i++) if (a[i]>gr/k) {cout << -1; return 0;};
sort (s.begin(), s.end()); long long int pr=0;
for (int i=0; i<s.size(); i++){
long long int x=s [i].first; long long int y=s[i].second.first; long long int t=s[i].second.second;
//cout << x << " " << y << " " << t << endl;
if (t==0){
if (x-pr!=0){
ans [ind].push_back (x-pr);
for (auto e:m){
ans [ind].push_back (e+1);
}
ind++;
}
m.insert (y);
}
else{
if (x-pr!=0){
ans [ind].push_back (x-pr);
for (auto e:m){
ans [ind].push_back (e+1);
}
ind++;
}
m.erase (y);
}
pr=x;
}
cout << ind << "\n";
for (int i=0; i<ind; i++){
for (int j=0; j<ans [i].size(); j++) cout << ans [i][j] << " ";
cout << "\n";
}
return 0;
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
