# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
593145 |
2022-07-10T12:59:36 Z |
ioi |
Sandcastle 2 (JOI22_ho_t5) |
C++14 |
|
7 ms |
852 KB |
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '[' << #x << " is: " << x << "] " << endl;
#define inF freopen("cardgame.in" , "r" , stdin);
#define outF freopen("cardgame.out" , "w" , stdout);
#define imod(a , n) (a % n + n ) % n
#define sor(v) sort(v.begin() , v.end());
#define print(v) for(auto f : v ) cout << f << " " ;
#define rsor(v) sort(v.rbegin() , v.rend());
#define rev(v) reverse(v.begin() , v.end());
#define scan(v)for(auto &it : v)cin >> it ;
#define ll long long
#define logar(x , y) log(x) / log(y)
#define __sum(n) n * (n + 1) / 2
#define __lcm(a , b) a / __gcd(a , b) * b
#define pii pair<int , int >
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
//#define int ll
const int N = 3e5 + 3, M = N * 4 , MX = 2e4 + 40;
const ll MOD = 998244353 , oo = 1e9 + 9 , OO = 1e18 , mod = MOD ;
const double pi = acos(-1) , eps = 1e-17 ;
int di[] = {1 , -1 , 0 , 0};
int dj[] = {0 , 0 , 1 , -1};
int32_t main()
{
// inF;
// inF;outF;
fastio;
//Welcome back without <TAWJIHI>
int n , m ;
cin >> n >> m ;
ll past = 1e8 , cnt = 0;
ll ans = 0 ;
int arr[n][m];
for(int i = 0 ; i < n ; i ++){
for(int j = 0 ; j < m ; j ++)cin >> arr[i][j];
}
for(int i = 0 ; i < m ; i ++){
if(arr[0][i] < past)cnt ++ ;
else ans += cnt * (cnt + 1) / 2 , cnt = 1 ;
past = arr[0][i];
}
ans += cnt * (cnt + 1) / 2 ;
past = 1e8 , cnt = 0 ;
for(int i = m - 1 ; i >= 0 ; i --){
if(arr[0][i] < past)cnt ++ ;
else ans += cnt * (cnt + 1) / 2 - cnt , cnt = 1 ;
past = arr[0][i];
}
ans += cnt * (cnt + 1) / 2 - cnt ;
cout << ans ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
312 KB |
Output is correct |
2 |
Correct |
5 ms |
852 KB |
Output is correct |
3 |
Correct |
5 ms |
852 KB |
Output is correct |
4 |
Correct |
7 ms |
852 KB |
Output is correct |
5 |
Correct |
5 ms |
844 KB |
Output is correct |
6 |
Correct |
6 ms |
852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
444 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |