Submission #392889

#TimeUsernameProblemLanguageResultExecution timeMemory
392889Ruxandra985Teams (CEOI11_tea)C++14
90 / 100
963 ms40292 KiB
#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]; FILE *fin = stdin; FILE *fout = stdout; int ok (int maxi , int n , int ok){ int now , a , b , st , dr , mid; now = n; 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; } if (ok) fprintf (fout,"%d " , now - w[st]); if (now - w[st] > maxi) return 0; while (now > w[st]){ if (ok) fprintf (fout,"%d ",v[now].second); now--; } if (ok) fprintf (fout,"\n"); } return 1; } int main() { int n , i , st , dr , mid , elem; 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]); st = v[n].first; dr = n; while (st <= dr){ mid = (st + dr)/2; if (ok(mid , n , 0)) dr = mid - 1; /// merge, cauti mai mic else st = mid + 1; } /// solutia e st (dim minima a echipei maxime) //printf ("%d ",st); ok(st , n , 1); return 0; }

Compilation message (stderr)

tea.cpp: In function 'int main()':
tea.cpp:73:12: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   73 |     fscanf (fin,"%d",&n);
      |     ~~~~~~~^~~~~~~~~~~~~
tea.cpp:75:16: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   75 |         fscanf (fin,"%d",&v[i].first);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...