Submission #201665

# Submission time Handle Problem Language Result Execution time Memory
201665 2020-02-11T16:39:20 Z SamAnd Unija (COCI17_unija) C++17
100 / 100
441 ms 20728 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 1000006;
struct ban
{
    int x, y;
};
bool operator<(const ban& a, const ban& b)
{
    return a.x < b.x;
}

int n;
ban a[N];

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
    {
        scanf("%d%d", &a[i].x, &a[i].y);
        a[i].x /= 2;
    }
    sort(a + 1, a + n + 1);
    long long ans = 0;
    int maxu = 0;
    for (int i = n; i >= 1; --i)
    {
        maxu = max(maxu, a[i].y);
        ans += (a[i].x - a[i - 1].x) * 1LL * maxu;
    }
    ans *= 2;
    printf("%lld\n", ans);
    return 0;
}

Compilation message

unija.cpp: In function 'int main()':
unija.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &n);
     ~~~~~^~~~~~~~~~
unija.cpp:21:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d", &a[i].x, &a[i].y);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 376 KB Output is correct
2 Correct 7 ms 376 KB Output is correct
3 Correct 3 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 421 ms 20220 KB Output is correct
2 Correct 428 ms 20728 KB Output is correct
3 Correct 422 ms 20476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 888 KB Output is correct
2 Correct 15 ms 888 KB Output is correct
3 Correct 18 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 43 ms 2424 KB Output is correct
2 Correct 42 ms 2424 KB Output is correct
3 Correct 42 ms 2552 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 122 ms 6840 KB Output is correct
2 Correct 124 ms 6760 KB Output is correct
3 Correct 119 ms 6648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 431 ms 19992 KB Output is correct
2 Correct 441 ms 20600 KB Output is correct
3 Correct 416 ms 20704 KB Output is correct