Submission #287855

# Submission time Handle Problem Language Result Execution time Memory
287855 2020-09-01T04:51:53 Z dantoh000 Bigger segments (IZhO19_segments) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef pair<int,ll> ii;
typedef long long ll;
int n;
int a[500005];
ii dp[500005];
ll p[500005];
int main(){
    scanf("%d",&n);
    for (int i = 1 ; i <= n; i++){
        scanf("%d",&a[i]);
        p[i] = p[i-1]+a[i];
    }
    dp[0] = ii(0,0);
    for (int i = 1; i <= n; i++){
        for (int j = 0; j < i; j++){
            if (p[i]-p[j] >= dp[j].se){
                if (dp[i].fi < dp[j].fi+1 || (dp[i].fi == dp[j].fi+1 && dp[i].se > p[i]-p[j]) ){
                    dp[i] = {dp[j].fi+1, p[i]-p[j]};
                }
            }
        }
    }
    printf("%d\n",dp[n].fi);
}

Compilation message

segments.cpp:5:18: error: 'll' was not declared in this scope
    5 | typedef pair<int,ll> ii;
      |                  ^~
segments.cpp:5:20: error: template argument 2 is invalid
    5 | typedef pair<int,ll> ii;
      |                    ^
segments.cpp: In function 'int main()':
segments.cpp:17:19: error: expression list treated as compound expression in functional cast [-fpermissive]
   17 |     dp[0] = ii(0,0);
      |                   ^
segments.cpp:17:16: warning: left operand of comma operator has no effect [-Wunused-value]
   17 |     dp[0] = ii(0,0);
      |                ^
segments.cpp:3:12: error: request for member 'second' in 'dp[j]', which is of non-class type 'ii' {aka 'int'}
    3 | #define se second
      |            ^~~~~~
segments.cpp:20:36: note: in expansion of macro 'se'
   20 |             if (p[i]-p[j] >= dp[j].se){
      |                                    ^~
segments.cpp:2:12: error: request for member 'first' in 'dp[i]', which is of non-class type 'ii' {aka 'int'}
    2 | #define fi first
      |            ^~~~~
segments.cpp:21:27: note: in expansion of macro 'fi'
   21 |                 if (dp[i].fi < dp[j].fi+1 || (dp[i].fi == dp[j].fi+1 && dp[i].se > p[i]-p[j]) ){
      |                           ^~
segments.cpp:2:12: error: request for member 'first' in 'dp[j]', which is of non-class type 'ii' {aka 'int'}
    2 | #define fi first
      |            ^~~~~
segments.cpp:21:38: note: in expansion of macro 'fi'
   21 |                 if (dp[i].fi < dp[j].fi+1 || (dp[i].fi == dp[j].fi+1 && dp[i].se > p[i]-p[j]) ){
      |                                      ^~
segments.cpp:2:12: error: request for member 'first' in 'dp[i]', which is of non-class type 'ii' {aka 'int'}
    2 | #define fi first
      |            ^~~~~
segments.cpp:21:53: note: in expansion of macro 'fi'
   21 |                 if (dp[i].fi < dp[j].fi+1 || (dp[i].fi == dp[j].fi+1 && dp[i].se > p[i]-p[j]) ){
      |                                                     ^~
segments.cpp:2:12: error: request for member 'first' in 'dp[j]', which is of non-class type 'ii' {aka 'int'}
    2 | #define fi first
      |            ^~~~~
segments.cpp:21:65: note: in expansion of macro 'fi'
   21 |                 if (dp[i].fi < dp[j].fi+1 || (dp[i].fi == dp[j].fi+1 && dp[i].se > p[i]-p[j]) ){
      |                                                                 ^~
segments.cpp:3:12: error: request for member 'second' in 'dp[i]', which is of non-class type 'ii' {aka 'int'}
    3 | #define se second
      |            ^~~~~~
segments.cpp:21:79: note: in expansion of macro 'se'
   21 |                 if (dp[i].fi < dp[j].fi+1 || (dp[i].fi == dp[j].fi+1 && dp[i].se > p[i]-p[j]) ){
      |                                                                               ^~
segments.cpp:2:12: error: request for member 'first' in 'dp[j]', which is of non-class type 'ii' {aka 'int'}
    2 | #define fi first
      |            ^~~~~
segments.cpp:22:36: note: in expansion of macro 'fi'
   22 |                     dp[i] = {dp[j].fi+1, p[i]-p[j]};
      |                                    ^~
segments.cpp:22:51: error: cannot convert '<brace-enclosed initializer list>' to 'ii' {aka 'int'} in assignment
   22 |                     dp[i] = {dp[j].fi+1, p[i]-p[j]};
      |                                                   ^
segments.cpp:2:12: error: request for member 'first' in 'dp[n]', which is of non-class type 'ii' {aka 'int'}
    2 | #define fi first
      |            ^~~~~
segments.cpp:27:25: note: in expansion of macro 'fi'
   27 |     printf("%d\n",dp[n].fi);
      |                         ^~
segments.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   12 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
segments.cpp:14:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   14 |         scanf("%d",&a[i]);
      |         ~~~~~^~~~~~~~~~~~