Submission #335829

#TimeUsernameProblemLanguageResultExecution timeMemory
335829beksultan04Hedgehog Daniyar and Algorithms (IZhO19_sortbooks)C++14
17 / 100
403 ms262144 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define OK puts("OK");
#define fr first
#define sc second
#define ret return
#define scan1(a) scanf("%lld",&a);
#define scan2(a,b) scanf("%lld %lld",&a, &b);
#define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
#define all(s) s.begin(),s.end()
#define pb push_back
#define endi puts("");
const int N = 1e6+12,INF=1e9+7;
int q[N],der[N],dp[5001][5001];
main(){
    int n,t,i,j,k;
    scan2(n,t)
    for (i=1;i<=n;++i){
        scan1(q[i])
        for (j=i-1;j>0;--j){
            if (q[i] < q[j])
                dp[i][j] = max(dp[i][j+1],q[i]+q[j]);
            else {
                dp[i][j] = dp[i][j+1];
            }
            dp[i][j] = max(dp[i][j],dp[i-1][j]);
        }
    }
    while (t--){
        int l,r,k;
        scan3(l,r,k)
        cout <<(dp[r][l]<=k)<<"\n";
    }

}

Compilation message (stderr)

sortbooks.cpp:17:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   17 | main(){
      |      ^
sortbooks.cpp: In function 'int main()':
sortbooks.cpp:18:17: warning: unused variable 'k' [-Wunused-variable]
   18 |     int n,t,i,j,k;
      |                 ^
sortbooks.cpp:10:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   10 | #define scan2(a,b) scanf("%lld %lld",&a, &b);
      |                    ~~~~~^~~~~~~~~~~~~~~~~~~~
sortbooks.cpp:19:5: note: in expansion of macro 'scan2'
   19 |     scan2(n,t)
      |     ^~~~~
sortbooks.cpp:9:23: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 | #define scan1(a) scanf("%lld",&a);
      |                  ~~~~~^~~~~~~~~~~
sortbooks.cpp:21:9: note: in expansion of macro 'scan1'
   21 |         scan1(q[i])
      |         ^~~~~
sortbooks.cpp:11:27: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 | #define scan3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c);
      |                      ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
sortbooks.cpp:33:9: note: in expansion of macro 'scan3'
   33 |         scan3(l,r,k)
      |         ^~~~~
#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...