# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
392742 | Ruxandra985 | Teams (CEOI11_tea) | C++14 | 424 ms | 39536 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define DIMN 1000010
using namespace std;
int dp[DIMN];
int mp[DIMN];
int tt[DIMN];
int w[DIMN] , poz[DIMN];
pair <int , int> v[DIMN];
int main()
{
FILE *fin = stdin;
FILE *fout = stdout;
int n , i , now , st , dr , mid , elem , a , b;
fscanf (fin,"%d",&n);
for (i = 1 ; i <= n ; i++){
fscanf (fin,"%d",&v[i].first);
v[i].second = i;
}
sort (v + 1 , v + n + 1);
elem = 0;
for (i = 1 ; i <= n ; i++){
if (i - v[i].first < 0){
dp[i] = -2000000000;
mp[i] = mp[i - 1];
tt[i] = -1;
}
else {
dp[i] = mp[i - v[i].first] + 1;
w[++elem] = i;
poz[i] = elem;
tt[i] = i - v[i].first;
mp[i] = max(mp[i - 1] , dp[i]);
}
}
fprintf (fout,"%d\n" , dp[n]);
now = n;
int maxi = now - tt[now];
while (now){ /// nu pare o idee buna ce fac....
a = max(0 , now - maxi); /// ma asigur ca v2 nu e -1
/// cea mai mica echipa posibila ar fi de v[now].first
b = now - v[now].first;
while (tt[b] == -1)
b--;
/// a <= b
if (a > b)
swap(a , b);
a = poz[a];
b = poz[b];
st = a;
dr = b;
while (st <= dr){
mid = (st + dr)/2;
if (dp[w[mid]] + 1 == dp[now])
dr = mid - 1;
else st = mid + 1;
}
fprintf (fout,"%d " , now - w[st]);
maxi = max(maxi , now - w[st]);
while (now > w[st]){
fprintf (fout,"%d ",v[now].second);
now--;
}
fprintf (fout,"\n");
}
return 0;
}
Compilation message (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... |