Submission #392682

#TimeUsernameProblemLanguageResultExecution timeMemory
392682Ruxandra985Teams (CEOI11_tea)C++14
0 / 100
2578 ms76316 KiB
#include <bits/stdc++.h> #define DIMN 1000010 using namespace std; int dp[DIMN]; int mp[DIMN]; pair <int , int> v[DIMN]; int main() { FILE *fin = stdin; FILE *fout = stdout; int n , i , now , st , dr , mid , cnt; 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); for (i = 1 ; i <= n ; i++){ if (i - v[i].first < 0){ dp[i] = -2000000000; mp[i] = mp[i - 1]; } else { dp[i] = mp[i - v[i].first] + 1; mp[i] = max(mp[i - 1] , dp[i]); } } fprintf (fout,"%d\n" , dp[n]); now = n; while (now){ /// nu pare o idee buna ce fac.... st = v[now].first; dr = now; while (st <= dr){ mid = (st + dr) / 2; if (mp[now - mid] + 1 != dp[now]) /// nu e bun st = mid + 1; else dr = mid - 1; } /// solutia e in dr (ultimul care se poate) fprintf (fout,"%d " , st); for (i = 1 ; i <= st ; i++ , now--){ fprintf (fout,"%d ",v[now].second); } fprintf (fout,"\n"); } return 0; }

Compilation message (stderr)

tea.cpp: In function 'int main()':
tea.cpp:13:39: warning: unused variable 'cnt' [-Wunused-variable]
   13 |     int n , i , now , st , dr , mid , cnt;
      |                                       ^~~
tea.cpp:14:12: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |     fscanf (fin,"%d",&n);
      |     ~~~~~~~^~~~~~~~~~~~~
tea.cpp:16:16: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   16 |         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...