Submission #1088334

# Submission time Handle Problem Language Result Execution time Memory
1088334 2024-09-14T09:05:43 Z vjudge1 Discharging (NOI20_discharging) C++17
47 / 100
78 ms 17872 KB
#include<bits/stdc++.h>
#define taskname ""
#define el '\n'
#define fi first
#define sc second
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
#define int long long
using namespace std;
#define Faster ios_base::sync_with_stdio(false);cin.tie(0);
const int maxn=1e6+33;
const int N=1e5;
const int mod=1e9+7;
const long long INF=1e18+2;
int n,cost[1505][1505],a[maxn];
int dp[maxn];
void sub1()
{
    for(int i=1;i<=n;i++)
    {
        cost[i][i]=a[i];
        for(int j=i+1;j<=n;j++)
        {
            cost[i][j]=max(cost[i][j-1],a[j]);
        }
    }
    for(int i=1;i<=n;i++)
    {
        dp[i]=cost[1][i]*n;
        for(int j=1;j<i;j++)
        {
            dp[i]=min(dp[i],dp[j]+cost[j+1][i]*(n-j));
        }
    }
    cout<<dp[n];
}
void sub2()
{
    cout<<a[1]*n;
}
signed main()
{
    if (fopen(taskname".INP","r"))
    {
        freopen(taskname".INP","r",stdin);
        freopen(taskname".OUT","w",stdout);
    }
    Faster
    cin>>n;
    int inc=0,dec=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(i>1&&a[i]>a[i-1]) inc=1;
        if(i>1&&a[i]<a[i-1]) dec=1;
    }
    if(n<=1500) sub1();
    else if(inc==0) sub2();
}


Compilation message

Discharging.cpp: In function 'int main()':
Discharging.cpp:50:15: warning: variable 'dec' set but not used [-Wunused-but-set-variable]
   50 |     int inc=0,dec=0;
      |               ^~~
Discharging.cpp:45:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |         freopen(taskname".INP","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
Discharging.cpp:46:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |         freopen(taskname".OUT","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 388 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 13916 KB Output is correct
2 Correct 7 ms 13476 KB Output is correct
3 Correct 7 ms 13656 KB Output is correct
4 Correct 7 ms 13276 KB Output is correct
5 Correct 7 ms 13948 KB Output is correct
6 Correct 7 ms 13660 KB Output is correct
7 Correct 8 ms 13660 KB Output is correct
8 Correct 7 ms 13144 KB Output is correct
9 Correct 8 ms 13864 KB Output is correct
10 Correct 7 ms 13144 KB Output is correct
11 Correct 7 ms 13944 KB Output is correct
12 Correct 7 ms 13660 KB Output is correct
13 Correct 7 ms 13076 KB Output is correct
14 Correct 8 ms 14020 KB Output is correct
15 Correct 7 ms 13516 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 13916 KB Output is correct
2 Correct 7 ms 13476 KB Output is correct
3 Correct 7 ms 13656 KB Output is correct
4 Correct 7 ms 13276 KB Output is correct
5 Correct 7 ms 13948 KB Output is correct
6 Correct 7 ms 13660 KB Output is correct
7 Correct 8 ms 13660 KB Output is correct
8 Correct 7 ms 13144 KB Output is correct
9 Correct 8 ms 13864 KB Output is correct
10 Correct 7 ms 13144 KB Output is correct
11 Correct 7 ms 13944 KB Output is correct
12 Correct 7 ms 13660 KB Output is correct
13 Correct 7 ms 13076 KB Output is correct
14 Correct 8 ms 14020 KB Output is correct
15 Correct 7 ms 13516 KB Output is correct
16 Incorrect 50 ms 13140 KB Output isn't correct
17 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 65 ms 17744 KB Output is correct
2 Correct 78 ms 17744 KB Output is correct
3 Correct 73 ms 17724 KB Output is correct
4 Correct 71 ms 17872 KB Output is correct
5 Correct 73 ms 17748 KB Output is correct
6 Correct 70 ms 17748 KB Output is correct
7 Correct 72 ms 17748 KB Output is correct
8 Correct 71 ms 17796 KB Output is correct
9 Correct 73 ms 17748 KB Output is correct
10 Correct 74 ms 17764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 388 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 7 ms 13916 KB Output is correct
16 Correct 7 ms 13476 KB Output is correct
17 Correct 7 ms 13656 KB Output is correct
18 Correct 7 ms 13276 KB Output is correct
19 Correct 7 ms 13948 KB Output is correct
20 Correct 7 ms 13660 KB Output is correct
21 Correct 8 ms 13660 KB Output is correct
22 Correct 7 ms 13144 KB Output is correct
23 Correct 8 ms 13864 KB Output is correct
24 Correct 7 ms 13144 KB Output is correct
25 Correct 7 ms 13944 KB Output is correct
26 Correct 7 ms 13660 KB Output is correct
27 Correct 7 ms 13076 KB Output is correct
28 Correct 8 ms 14020 KB Output is correct
29 Correct 7 ms 13516 KB Output is correct
30 Correct 9 ms 13400 KB Output is correct
31 Correct 8 ms 13916 KB Output is correct
32 Correct 8 ms 13148 KB Output is correct
33 Correct 8 ms 13660 KB Output is correct
34 Correct 8 ms 13404 KB Output is correct
35 Correct 8 ms 13944 KB Output is correct
36 Correct 7 ms 13748 KB Output is correct
37 Correct 7 ms 13776 KB Output is correct
38 Correct 7 ms 13916 KB Output is correct
39 Correct 7 ms 13916 KB Output is correct
40 Correct 6 ms 13148 KB Output is correct
41 Correct 7 ms 13940 KB Output is correct
42 Correct 8 ms 14168 KB Output is correct
43 Correct 9 ms 14172 KB Output is correct
44 Correct 8 ms 13404 KB Output is correct
45 Correct 7 ms 13404 KB Output is correct
46 Correct 8 ms 13404 KB Output is correct
47 Correct 8 ms 14172 KB Output is correct
48 Correct 9 ms 13296 KB Output is correct
49 Correct 7 ms 13144 KB Output is correct
50 Correct 7 ms 13276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 388 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 604 KB Output is correct
15 Correct 7 ms 13916 KB Output is correct
16 Correct 7 ms 13476 KB Output is correct
17 Correct 7 ms 13656 KB Output is correct
18 Correct 7 ms 13276 KB Output is correct
19 Correct 7 ms 13948 KB Output is correct
20 Correct 7 ms 13660 KB Output is correct
21 Correct 8 ms 13660 KB Output is correct
22 Correct 7 ms 13144 KB Output is correct
23 Correct 8 ms 13864 KB Output is correct
24 Correct 7 ms 13144 KB Output is correct
25 Correct 7 ms 13944 KB Output is correct
26 Correct 7 ms 13660 KB Output is correct
27 Correct 7 ms 13076 KB Output is correct
28 Correct 8 ms 14020 KB Output is correct
29 Correct 7 ms 13516 KB Output is correct
30 Incorrect 50 ms 13140 KB Output isn't correct
31 Halted 0 ms 0 KB -