Submission #392742

#TimeUsernameProblemLanguageResultExecution timeMemory
392742Ruxandra985Teams (CEOI11_tea)C++14
30 / 100
424 ms39536 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]; 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)

tea.cpp: In function 'int main()':
tea.cpp:17:12: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   17 |     fscanf (fin,"%d",&n);
      |     ~~~~~~~^~~~~~~~~~~~~
tea.cpp:19:16: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   19 |         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...