Value

9.8万

Escort

constintnb

_N

GGGGG
Jack_FuDan

Æccêleγatσr
18203169320
@@-@
Once.
cs.s

zombotany

995740977

Value
7个月前
class Solution {
public:
int getSum(int n) {
return (long long) n * (n + 1) / 2;
}
};


Value
8个月前
#include <iostream>
using namespace std;
const int N = 1010;
bool flag[N];
int s[N];
int main(){
int n;  cin >> n;
for(int i = 0; i < n; i ++ ){
int t;  cin >> t;
s[t] ++ ;
flag[t] = true;
}
for(int i = 0; i < N; i ++ )    s[i] += s[i - 1];
int res = -1;
for(int i = 0; i < N; i ++ ){
if(!flag[i])    continue;
if(s[i - 1] == s[N - 1] - s[i]){
res = i;
break;
}
}
cout << res << endl;
return 0;
}


Value
8个月前
#include <iostream>
using namespace std;
const int N = 1010;
bool flag[N];
int s[N];
int main(){
int n;  cin >> n;
for(int i = 0; i < n; i ++ ){
int t;  cin >> t;
s[t] ++ ;
flag[t] = true;
}
for(int i = 0; i < N; i ++ )    s[i] += s[i - 1];
int res = -1;
for(int i = 0; i < N; i ++ ){
if(!flag[i])    continue;
if(s[i - 1] == s[N - 1] - s[i]){
res = i;
break;
}
}
cout << res << endl;
return 0;
}


Value
8个月前
#include <iostream>
using namespace std;
const int N = 30;
int graph[N][N];
int t[4][4];
bool check(int row, int col){
for(int i = 0; i < 4; i ++ ){
for(int j = 0; j < 4; j ++ ){
if(i + row >= 15 && t[i][j] == 1)   return true;
if(graph[i + row][j + col] && t[i][j])  return true;
}
}
return false;
}
int main(){
for(int i = 0; i < 15; i ++ )
for(int j = 0; j < 10; j ++ )
cin >> graph[i][j];
for(int i = 0; i < 4; i ++ )
for(int j = 0; j < 4; j ++ )
cin >> t[i][j];

int col;    cin >> col;
col -- ;
int k = 1;
while(k < 15){
if(check(k, col))   break;
k ++ ;
}
k -- ;
for(int i = k; i < k + 4; i ++ ){
for(int j = col; j < col + 4; j ++ )
graph[i][j] = t[i - k][j - col] == 0 ? graph[i][j] : 1;
}
for(int i = 0; i < 15; i ++ ){
for(int j = 0; j < 10; j ++ ){
cout << graph[i][j] << ' ';
}
cout << endl;
}
return 0;
}


Value
8个月前
#include <iostream>
using namespace std;
const int N = 30;
int graph[N][N];
int t[4][4];
bool check(int row, int col){
for(int i = 0; i < 4; i ++ ){
for(int j = 0; j < 4; j ++ ){
if(i + row >= 15 && t[i][j] == 1)   return true;
if(graph[i + row][j + col] && t[i][j])  return true;
}
}
return false;
}
int main(){
for(int i = 0; i < 15; i ++ )
for(int j = 0; j < 10; j ++ )
cin >> graph[i][j];
for(int i = 0; i < 4; i ++ )
for(int j = 0; j < 4; j ++ )
cin >> t[i][j];

int col;    cin >> col;
col -- ;
int k = 1;
while(k < 15){
if(check(k, col))   break;
k ++ ;
}
k -- ;
for(int i = k; i < k + 4; i ++ ){
for(int j = col; j < col + 4; j ++ )
graph[i][j] = t[i - k][j - col] == 0 ? graph[i][j] : 1;
}
for(int i = 0; i < 15; i ++ ){
for(int j = 0; j < 10; j ++ ){
cout << graph[i][j] << ' ';
}
cout << endl;
}
return 0;
}


Value
8个月前
#include <iostream>
using namespace std;
int main(){
int n;  cin >> n;
int status = 0, res = 0;
int pre = -1;
for(int i = 0; i < n; i ++ ){
int tmp;    cin >> tmp;
if(pre == -1) pre = tmp;
else if(pre > tmp){
if(status){
if(status > 0)  res ++ , status = -1;
}else   status = -1;
pre = tmp;
}else if(pre < tmp){
if(status){
if(status < 0)  res ++ , status = 1;
}else   status = 1;
pre = tmp;
}
}
cout << res << endl;
return 0;
}


Value
8个月前
#include <iostream>
using namespace std;
int main(){
int score = 0, t;
int pre = 0;
while(cin >> t && t){
if(t == 1)  pre = 1, score += t;
else{
if(pre == 1)    pre = 2, score += 2;
else    pre = pre + 2, score += pre;
}
}
cout << score << endl;
return 0;
}



Value
8个月前
#include <iostream>
#define x first
#define y second
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int N = 2e3 + 10;
pii a[N], b[N];
ll cmp(int i, int j){
if(a[i].x <= b[j].x && b[j].x <= a[i].y)    return min(a[i].y, b[j].y) - b[j].x;
else if(a[i].x >= b[j].x && a[i].x <= b[j].y)   return min(b[j].y, a[i].y) - a[i].x;
return 0;
}
int main(){
int n;  cin >> n;
for(int i = 0; i < n; i ++ )    cin >> a[i].x >> a[i].y;
for(int i = 0; i < n; i ++ )    cin >> b[i].x >> b[i].y;
ll res = 0;
for(int i = 0; i < n; i ++ )
for(int j = 0; j <= n; j ++ )
res += cmp(i, j);
cout << res << endl;
return 0;
}


Value
8个月前
#include <iostream>
#define x first
#define y second
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int N = 2e3 + 10;
pii a[N], b[N];
ll cmp(int i, int j){
if(a[i].x <= b[j].x && b[j].x <= a[i].y)    return min(a[i].y, b[j].y) - b[j].x;
else if(a[i].x >= b[j].x && a[i].x <= b[j].y)   return min(b[j].y, a[i].y) - a[i].x;
return 0;
}
int main(){
int n;  cin >> n;
for(int i = 0; i < n; i ++ )    cin >> a[i].x >> a[i].y;
for(int i = 0; i < n; i ++ )    cin >> b[i].x >> b[i].y;
ll res = 0;
for(int i = 0; i < n; i ++ )
for(int j = 0; j <= n; j ++ )
res += cmp(i, j);
cout << res << endl;
return 0;
}


Value
8个月前
#include <iostream>
using namespace std;
const int N = 1010;
int a[N];
int main(){
int n;  cin >> n;
for(int i = 0; i < n; i ++ )    scanf("%d", &a[i]);
for(int i = 0; i < n; i ++ ){
if(i == 0)  cout << (a[1] + a[0]) / 2;
else if(i == n - 1) cout << (a[n - 2] + a[i]) / 2;
else    cout << (a[i - 1] + a[i] + a[i + 1]) / 3;
if(i == n - 1)  cout << endl;
else    cout << ' ';
}
return 0;
}