# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1111675 | khoaha123 | Teams (CEOI11_tea) | C++17 | 392 ms | 262144 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define endl '\n'
#define ii pair<int,int>
#define task "DIVTEAM"
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
const int N = 1e6 + 5;
const int mod = 1e9 + 7;
const int INF = 1e9;
const double EPS = 1e-9;
const int dx[2] = {1,0};
const int dy[2] = {0,1};
int n,a[N];
vector<int> b[N];
vector<vector<int>> ans;
int dp[N],pos[N];
int check(int T){
dp[0] = 0;
for (int i = 1; i <= n; ++i){
if (i >= a[i] && i - pos[i - a[i]] <= T) dp[i] = dp[pos[i - a[i]]] + 1;
pos[i] = (dp[pos[i-1]] > dp[i] ? pos[i-1] : i);
}
return dp[n];
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
if (fopen(task".INP","r")){
freopen(task".INP","r",stdin);
freopen(task".OUT","w",stdout);
}
cin >> n;
for (int i = 1; i <= n; ++i){
cin >> a[i];
b[a[i]].push_back(i);
}
sort(a+1,a+1+n);
int result = check(n);
int l = 0,r = n;
while (r - l > 1){
int mid = (l + r) >> 1;
if (check(mid) == result) r = mid;
else l = mid;
}
check(r);
int u = n;
while (u){
int t = pos[u -a[u]];
vector<int> x;
while (u > t){
x.push_back(b[a[u]].back());
b[a[u]].pop_back();
u--;
}
ans.push_back(x);
}
cout << ans.size() << endl;
for (auto f : ans){
cout << f.size() << ' ';
for (auto g : f) cout << g << ' ';
cout << endl;
}
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... |
# | 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... |