Submission #143930

# Submission time Handle Problem Language Result Execution time Memory
143930 2019-08-15T13:12:45 Z WhipppedCream Art Exhibition (JOI18_art) C++17
Compilation error
0 ms 0 KB
//Power Of Ninja Go
#include <bits/stdc++.h>
//#ifdef atom #else #endif
using namespace std;
typedef long long ll; typedef pair<ll, ll> ii; typedef vector<int> vi; typedef vector< ii > vii;
#define X first
#define Y second
#define pb push_back
vii tahm;
const int maxn = 5e5+5;
ll qs[maxn];
ll x[maxn], y[maxn];
int main()
{
    int n; scanf("%d", &n);
    for(int i = 0; i< n; i++)
    {
        tahm.pb(ii());
        scanf("%lld %lld", &tahm.back().X, &tahm.back().Y);
    }
    sort(tahm.begin(), tahm.end());
    for(int i = 1; i<= n; i++)
    {
        qs[i] = qs[i-1] + tahm[i-1].Y;
    }
    for(int i = 1; i<= n; i++) x[i] = qs[i]-tahm[i-1].X;
    for(int i = 1; i<= n; i++) y[i] = qs[i-1]-tahm[i-1].X;
    //for(int i = 1; i<= n; i++) cout << x[i] << " " << y[i] << endl;
    ll best = 1e18;
    ll res = -1e18;
    for(int i = 1; i<= n; i++)
    {
        best = min(best, y[i]);
        res = max(res, x[i]-best);
    }
    printf("%lld\n", res);
}
//Power Of Ninja Go
#include <bits/stdc++.h>
//#ifdef atom #else #endif
using namespace std;
typedef long long ll; typedef pair<ll, ll> ii; typedef vector<int> vi; typedef vector< ii > vii;
#define X first
#define Y second
#define pb push_back
vii tahm;
const int maxn = 5e5+5;
ll qs[maxn];
ll x[maxn], y[maxn];
int main()
{
    int n; scanf("%d", &n);
    for(int i = 0; i< n; i++)
    {
        tahm.pb(ii());
        scanf("%lld %lld", &tahm.back().X, &tahm.back().Y);
    }
    sort(tahm.begin(), tahm.end());
    for(int i = 1; i<= n; i++)
    {
        qs[i] = qs[i-1] + tahm[i-1].Y;
    }
    for(int i = 1; i<= n; i++) x[i] = qs[i]-tahm[i-1].X;
    for(int i = 1; i<= n; i++) y[i] = qs[i-1]-tahm[i-1].X;
    //for(int i = 1; i<= n; i++) cout << x[i] << " " << y[i] << endl;
    ll best = 1e18;
    ll res = -1e18;
    for(int i = 1; i<= n; i++)
    {
        best = min(best, y[i]);
        res = max(res, x[i]-best);
    }
    printf("%lld\n", res);
}

Compilation message

art.cpp:46:5: error: redefinition of 'vii tahm'
 vii tahm;
     ^~~~
art.cpp:9:5: note: 'vii tahm' previously declared here
 vii tahm;
     ^~~~
art.cpp:47:11: error: redefinition of 'const int maxn'
 const int maxn = 5e5+5;
           ^~~~
art.cpp:10:11: note: 'const int maxn' previously defined here
 const int maxn = 5e5+5;
           ^~~~
art.cpp:48:11: error: redefinition of 'll qs [500005]'
 ll qs[maxn];
           ^
art.cpp:11:4: note: 'll qs [500005]' previously declared here
 ll qs[maxn];
    ^~
art.cpp:49:10: error: redefinition of 'll x [500005]'
 ll x[maxn], y[maxn];
          ^
art.cpp:12:4: note: 'll x [500005]' previously declared here
 ll x[maxn], y[maxn];
    ^
art.cpp:49:19: error: redefinition of 'll y [500005]'
 ll x[maxn], y[maxn];
                   ^
art.cpp:12:13: note: 'll y [500005]' previously declared here
 ll x[maxn], y[maxn];
             ^
art.cpp: In function 'int main()':
art.cpp:50:5: error: redefinition of 'int main()'
 int main()
     ^~~~
art.cpp:13:5: note: 'int main()' previously defined here
 int main()
     ^~~~
art.cpp: In function 'int main()':
art.cpp:15:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int n; scanf("%d", &n);
            ~~~~~^~~~~~~~~~
art.cpp:19:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %lld", &tahm.back().X, &tahm.back().Y);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
art.cpp: In function 'int main()':
art.cpp:52:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     int n; scanf("%d", &n);
            ~~~~~^~~~~~~~~~
art.cpp:56:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld %lld", &tahm.back().X, &tahm.back().Y);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~