답안 #392682

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
392682 2021-04-21T13:33:39 Z Ruxandra985 Teams (CEOI11_tea) C++14
0 / 100
2500 ms 76316 KB
#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

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);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Execution timed out 2578 ms 55748 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 2 ms 436 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2555 ms 54756 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2578 ms 55656 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2569 ms 55564 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2518 ms 55452 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2573 ms 57396 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2562 ms 70548 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2519 ms 75236 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 2564 ms 76316 KB Time limit exceeded
2 Halted 0 ms 0 KB -