답안 #282748

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
282748 2020-08-24T20:28:45 Z infinite_iq Count Squares (CEOI19_countsquares) C++14
100 / 100
2403 ms 141008 KB
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 340
#define mp make_pair
#define mid (l+r)/2
#define le node * 2 
#define ri node * 2 + 1 
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
#define all(x) x.begin(), x.end()
#define gc getchar_unlocked
typedef long long ll;
typedef short int si;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef pair<double,ll>pdi;
const ll inf=1e18;
const ll mod=998244353;
const ld Pi=acos(-1) ;
ll n , m , ans ;
ll a [1509] , b [1509] ;
map < ll , ll > num ;  
int main () {
        cin >> n >> m ;
        for ( int i = 0 ; i < n ; i ++ ) {
                cin >> a [i] ;
        }
        for ( int i = 0 ; i < m ; i ++ ) {
                cin >> b [i] ;
        }
        for ( int i = 0 ; i < n ; i ++ ) {
                for ( int j = 0 ; j < i ; j ++ ) {
                        num [a[i]-a[j]] ++ ;
                }
        }
        for ( int i = 0 ; i < m ; i ++ ) {
                for ( int j = 0 ; j < i ; j ++ ) {
                        ans += num [b[i]-b[j]] ;
                }
        }
        cout << ans << endl ;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 220 ms 22888 KB Output is correct
7 Correct 213 ms 22776 KB Output is correct
8 Correct 217 ms 22776 KB Output is correct
9 Correct 214 ms 22132 KB Output is correct
10 Correct 11 ms 768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 220 ms 22888 KB Output is correct
7 Correct 213 ms 22776 KB Output is correct
8 Correct 217 ms 22776 KB Output is correct
9 Correct 214 ms 22132 KB Output is correct
10 Correct 11 ms 768 KB Output is correct
11 Correct 2316 ms 141008 KB Output is correct
12 Correct 2331 ms 140952 KB Output is correct
13 Correct 2403 ms 140936 KB Output is correct
14 Correct 2269 ms 139176 KB Output is correct
15 Correct 93 ms 1400 KB Output is correct