Submission #262595

# Submission time Handle Problem Language Result Execution time Memory
262595 2020-08-13T04:57:54 Z 문홍윤(#5091) Pairs (IOI07_pairs) C++17
30 / 100
38 ms 2164 KB
#include <bits/stdc++.h>
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define svec(x) sort(x.begin(), x.end());
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;

int n, d, m;

void solve_1d(){
    vector<int> out, qu;
    scanf("%d %d %d", &n, &d, &m);
    for(int i=1; i<=n; i++){
        int p;
        scanf("%d", &p);
        out.eb(min(p+d+1, m+1));
        qu.eb(p);
    }
    svec(qu); svec(out);
    LL num=0, ans=0;
    int pv=0;
    for(auto i:qu){
        for(; pv<out.size(); pv++){
            if(out[pv]>i)break;
            num--;
        }
        ans+=num;
        num++;
    }
    printf("%lld", ans);
}

void solve_2d(){

}

void solve_3d(){

}

int main(){
    int dim;
    scanf("%d", &dim);
    if(dim==1)solve_1d();
    if(dim==2)solve_2d();
    if(dim==3)solve_3d();
}

/*
1 6 5 100
25 50 50 10 20 23
*/

Compilation message

pairs.cpp: In function 'void solve_1d()':
pairs.cpp:26:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for(; pv<out.size(); pv++){
      |               ~~^~~~~~~~~~~
pairs.cpp:15:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |     scanf("%d %d %d", &n, &d, &m);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
pairs.cpp:18:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |         scanf("%d", &p);
      |         ~~~~~^~~~~~~~~~
pairs.cpp: In function 'int main()':
pairs.cpp:46:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   46 |     scanf("%d", &dim);
      |     ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 1780 KB Output is correct
2 Correct 21 ms 1660 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 35 ms 2164 KB Output is correct
2 Correct 28 ms 2164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 38 ms 2164 KB Output is correct
2 Correct 34 ms 2164 KB Output is correct
3 Correct 33 ms 2164 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -